home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 39 / Amiga Format CD39 (1999-04-13)(Future Publishing)(GB)[!][issue 1999-05].iso / -seriously_amiga- / graphics / flashmandel / sources / flashmandel.c < prev    next >
C/C++ Source or Header  |  1999-03-08  |  139KB  |  4,103 lines

  1. /*******************************************************************************
  2. **
  3. **  Coded by Dino Papararo              11-Feb-1999
  4. **
  5. *******************************************************************************/
  6.  
  7. #define __USE_SYSBASE
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <proto/exec.h>
  13. #include <proto/dos.h>
  14. #include <proto/intuition.h>
  15. #include <proto/diskfont.h>
  16. #include <proto/graphics.h>
  17. #include <proto/gadtools.h>
  18. #include <proto/utility.h>
  19. #include <proto/iffparse.h>
  20. #include <proto/icon.h>
  21. #include <proto/asl.h>
  22. #include <exec/execbase.h>
  23. #include <exec/memory.h>
  24. #include <intuition/intuition.h>
  25. #include <intuition/gadgetclass.h>
  26. #include <graphics/gfxbase.h>
  27. #include <graphics/videocontrol.h>
  28. #include <graphics/scale.h>
  29. #include <iffp/ilbmapp.h>
  30. #include <devices/prtbase.h>
  31. #include <devices/printer.h>
  32.  
  33.  
  34.  
  35. /* To compile the FPU versions uncomment next line */
  36. #define __USE_FPU
  37.  
  38.  
  39. #ifdef __USE_FPU
  40. #include <m68881.h>
  41. #else
  42. #include <mieeedoub.h>
  43. #endif
  44.  
  45. #define FPU_68K 1 << 1L
  46. #define FPU_PPC 1 << 2L
  47.  
  48. #define VERSION  "FlashMandel 1.5 "
  49. #define AUTHOR   "Dino Papararo"
  50. #define DATE     __AMIGADATE__
  51. #define COPYRIGHT "©1996-99"
  52. #define ADDRESS  "Via Manzoni, 184\n  80123 Napoli\n  Italia"
  53. #define EMAIL    "E-Mail address:\n\n  DinoP@IName.Com\n\n"
  54.  
  55. #define INIT_DEF_RMIN      -2.2
  56. #define INIT_DEF_RMAX      +0.8
  57. #define INIT_DEF_IMIN      -1.125
  58. #define INIT_DEF_IMAX      +1.125
  59. #define INIT_DEF_RMINSTR   "-2.2"
  60. #define INIT_DEF_RMAXSTR   "+0.8"
  61. #define INIT_DEF_IMINSTR   "-1.125"
  62. #define INIT_DEF_IMAXSTR   "+1.125"
  63.  
  64. #define DEF_WIDTH        640
  65. #define DEF_HEIGHT       480
  66. #define DEF_DEPTH        4
  67. #define DEF_MONITOR      0x50011000
  68. #define DEF_MONITORSTR  "0x50011000"
  69. #define DEF_FONTNAME    "topaz.font\0"
  70. #define DEF_FONTSIZE     8
  71. #define DEF_STARTPRI    -3
  72.  
  73. #define MIN_WIDTH  640
  74. #define MIN_HEIGHT 480
  75. #define MAX_WIDTH  16368
  76. #define MAX_HEIGHT 16384
  77. #define MIN_DEPTH  3
  78. #define MAX_DEPTH  8
  79.  
  80. #define MAX_FONTSIZE 24
  81. #define MIN_FONTSIZE 8
  82.  
  83. #define MIN_ITERATIONS 31
  84.  
  85. #define RESERVED_PENS 4L
  86.  
  87. #define TOBLACK   1
  88. #define FROMBLACK 0
  89.  
  90. #define RAW_ESC      0x045
  91. #define VAN_ESC      0x01B
  92. #define TAB          0x042
  93.  
  94. #define FIXED_POINT      (28L)                /* Bit di Precisione */
  95. #define MAX_POT          (1L << FIXED_POINT)  /*   2^FIXED_POINT   */
  96.  
  97. #define MINLIMIT 2
  98.  
  99. #define BLACK      (0)
  100. #define LIGHT_GREY (2)
  101. #define WHITE      (1)
  102. #define DARK_GREY  (3)
  103.  
  104. #define POINTS       4
  105. #define PAIRS        5
  106.  
  107. #define MYSECS       (50L * 2L) /* 2 secondi */
  108.  
  109. #define SHIFTRIGHT   FALSE
  110. #define SHIFTLEFT    TRUE
  111.  
  112. #define INITIALZOOM  14
  113.  
  114. #define CLEAR_POINTER 0
  115. #define BUSY_POINTER  1
  116. #define ZOOM_POINTER  2
  117.  
  118. #define ZPW          15
  119. #define ZPH          15
  120. #define ZPXO         -8
  121. #define ZPYO         -7
  122.  
  123. #define MAXCHARS     20
  124.  
  125. #define ACCEPT       (1)
  126. #define RATIO        (2)
  127. #define RESET        (3)
  128. #define CANCEL       (4)
  129. #define KEEP         (5)
  130.  
  131. #define WMASK  0x1
  132. #define FMASK  0x2
  133. #define VMASK  0x4
  134. #define SMASK  0x8
  135. #define BMASK  0x10
  136. #define ZMASK  0x20
  137. #define TMASK  0x40
  138.  
  139. #define SPREAD_BIT   (1L << 16)
  140. #define REPEATED_BIT (1L << 17)
  141. #define TRUE_BIT     (1L << 18)
  142. #define INTEGER_BIT  (1L << 19)
  143. #define REAL_BIT     (1L << 21)
  144. #define PPC_BIT      (1L << 22)
  145. #define TITLE_BIT    (1L << 20)
  146.  
  147. #define LOADPICTURE_MSG 0x1
  148. #define SAVEPICTURE_MSG 0x2
  149. #define DUMP_MSG        0x4
  150. #define REDRAW_MSG      0x8
  151. #define UNDO_MSG        0x10
  152. #define DRAW_MSG        0x20
  153. #define PREVIEW_MSG     0x40
  154. #define NEWDISPLAY_MSG  0x80
  155. #define STOP_MSG        0x100
  156. #define EXIT_MSG        0x200
  157. #define COORDS_MSG      0x400
  158. #define ITER_MSG        0x800
  159. #define ABOUT_MSG       0x1000
  160. #define TITLE_MSG       0x2000
  161. #define TIME_MSG        0x4000
  162. #define PALETTE_MSG     0x8000
  163. #define CYCLERIGHT_MSG  0x10000
  164. #define CYCLELEFT_MSG   0x20000
  165. #define DELAY_MSG       0x40000
  166. #define COLOR_MSG       0x80000
  167. #define LOADPALETTE_MSG 0x100000
  168. #define SAVEPALETTE_MSG 0x200000
  169. #define FONTREQ_MSG     0x400000
  170.  
  171. #define PICTURES_DRAWER 0
  172. #define PALETTES_DRAWER 1
  173.  
  174. #define IDCMP_STANDARD  IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|IDCMP_MENUPICK
  175.  
  176. #define WFLG_STANDARD WFLG_ACTIVATE|WFLG_BACKDROP|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_BORDERLESS|WFLG_REPORTMOUSE|WFLG_NEWLOOKMENUS
  177.  
  178. #define TEXT_ALERT_POS  "\x00\x90\x10 FlashMandel message: "
  179.  
  180. #define MODE_ID_MASK (LACE|HIRES|HAM|EXTRA_HALFBRITE)
  181.  
  182. #define ID_MAND MAKE_ID('M','A','N','D')
  183.  
  184. struct MandelChunk { WORD LeftEdge,TopEdge,Width,Height;
  185.                      long double RMin,RMax,IMin,IMax;
  186.                      long double RConst,IConst;
  187.                      ULONG Iterations;
  188.                      ULONG Special;
  189.                    };
  190.  
  191. IMPORT struct ExecBase *SysBase;
  192.  
  193. TEXT VERSION_STRING [] = "\0$VER: " VERSION DATE "\r\n by " AUTHOR;
  194.  
  195. TEXT MYFILE [25],PICTURESDIR [220],PALETTESDIR [220],MYPATH [246],BAR_STRING [80],*MYDIR = NULL;
  196.  
  197. BOOL SPREAD = TRUE,DEPTH_CHANGED;
  198.  
  199. WORD ZOOMLINE [PAIRS << 1] , MAX_ITERATIONS = 319,RETURNVALUE = 0;
  200.  
  201. UWORD ITERATIONS;
  202.  
  203. LONG PRIORITY = DEF_STARTPRI,DELAY = 5L,__oslibversion = 38L;
  204.  
  205. ULONG MASK = TMASK;
  206.  
  207. ULONG ELAPSEDTIME = NULL,CURRENT_MAX_COLORS;
  208.  
  209. long double RMIN=INIT_DEF_RMIN,RMAX=INIT_DEF_RMAX,IMIN=INIT_DEF_IMIN,IMAX=INIT_DEF_IMAX;
  210.  
  211. long double DEF_RMIN,DEF_RMAX,DEF_IMIN,DEF_IMAX,URMIN,URMAX,UIMIN,UIMAX;
  212.  
  213. long double FACTOR=0.0,INCREMREAL=0.0,INCREMIMAG=0.0,CRE=0.0,CIM=0.0;
  214.  
  215. ULONG *PALETTE;
  216.  
  217. CPTR *VINFO = NULL;
  218.  
  219. WORD (*FUNCTION) (WORD,long double,long double);
  220.  
  221. VOID (*V_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
  222.  
  223. VOID (*H_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
  224.  
  225. UBYTE *OpenDisplayError       = TEXT_ALERT_POS "I need at least 8 colors, sorry." "\x00";
  226. UBYTE *FontError              = TEXT_ALERT_POS "Font failed" "\x00";
  227. UBYTE *NoMonitor              = TEXT_ALERT_POS "No monitor" "\x00";
  228. UBYTE *NoChips                = TEXT_ALERT_POS "No chips" "\x00";
  229. UBYTE *NoMem                  = TEXT_ALERT_POS "No mem" "\x00";
  230. UBYTE *NoChipMem              = TEXT_ALERT_POS "No chipmem" "\x00";
  231. UBYTE *PubNotUnique           = TEXT_ALERT_POS "Pub not unique" "\x00";
  232. UBYTE *UnknownMode            = TEXT_ALERT_POS "Unknown mode" "\x00";
  233. UBYTE *ScreenTooDeep          = TEXT_ALERT_POS "Screen too deep" "\x00";
  234. UBYTE *AttachScreen           = TEXT_ALERT_POS "Attach screen failed" "\x00";
  235. UBYTE *ModeNotAvailableError  = TEXT_ALERT_POS "Mode not available" "\x00";
  236. UBYTE *UnknownScrError        = TEXT_ALERT_POS "Unknown screen error" "\x00";
  237. UBYTE *VisualInfoError        = TEXT_ALERT_POS "Visualinfo failed" "\x00";
  238. UBYTE *WindowError            = TEXT_ALERT_POS "Openwindow failed" "\x00";
  239. UBYTE *MenuError              = TEXT_ALERT_POS "Menu failed" "\x00";
  240. UBYTE *GadgetError            = TEXT_ALERT_POS "Gadget error" "\x00";
  241. UBYTE *WindowGadgetError      = TEXT_ALERT_POS "Window gadget error" "\x00";
  242. UBYTE *PreviewWindowError     = TEXT_ALERT_POS "Preview window failed" "\x00";
  243. UBYTE *CreateDisplayError     = TEXT_ALERT_POS "Createdisplay error" "\x00";
  244. UBYTE *DimensionInfoError     = TEXT_ALERT_POS "Dimensioninfo error" "\x00";
  245. UBYTE *DisplayInfoError       = TEXT_ALERT_POS "Displayinfo error" "\x00";
  246. UBYTE *PaletteRequesterError  = TEXT_ALERT_POS "Palette requester error" "\x00";
  247. UBYTE *MakeDisplayError       = TEXT_ALERT_POS "Display error" "\x00";
  248. UBYTE *QueryMandPicError      = TEXT_ALERT_POS "Not a FlashMandel picture !" "\x00";
  249. UBYTE *LoadMandPicError       = TEXT_ALERT_POS "Load picture error" "\x00";
  250. UBYTE *SaveMandPicError       = TEXT_ALERT_POS "Save picture error" "\x00";
  251. UBYTE *LoadMandPalError       = TEXT_ALERT_POS "Load palette error" "\x00";
  252. UBYTE *SaveMandPalError       = TEXT_ALERT_POS "Save palette error" "\x00";
  253.  
  254. VOID   PutPointer    (struct Window *,UWORD *,LONG,LONG,LONG,LONG,UBYTE);
  255. VOID   ClipIt        (WORD,WORD,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,BOOL);
  256. ULONG  ModeFallBack  (ULONG,WORD,WORD,WORD);
  257. LONG   About         (struct Window *);
  258. LONG   Choice        (struct Window *,TEXT *,TEXT *);
  259. LONG   CheckGFX      (VOID);
  260. BOOL   CheckEHB      (ULONG);
  261. UBYTE  GetMaxPlanes  (ULONG);
  262. ULONG  CheckFPU      (UWORD);
  263. VOID   AdjustRatio   (long double *,long double *,long double *,long double *,WORD,WORD,BOOL);
  264. WORD   Integer       (WORD,long double,long double);
  265. WORD   Real          (WORD,long double,long double);
  266. VOID   ShowTime      (struct Window *,TEXT *,ULONG);
  267. ULONG  IntegerGad    (struct Window *,TEXT *,TEXT *,TEXT *,ULONG);
  268. VOID   CloseDisplay  (struct ILBMInfo *,CPTR *);
  269. LONG   MakeDisplay   (struct ILBMInfo *);
  270. VOID   VLine_R_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  271. VOID   HLine_R_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  272. VOID   VLine_S_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  273. VOID   HLine_S_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  274. VOID   VLine_R       (struct RastPort *,const LONG,const LONG,const LONG);
  275. VOID   HLine_R       (struct RastPort *,const LONG,const LONG,const LONG);
  276. VOID   VLine_S       (struct RastPort *,const LONG,const LONG,const LONG);
  277. VOID   HLine_S       (struct RastPort *,const LONG,const LONG,const LONG);
  278. BOOL   CheckBox      (struct RastPort *,const LONG,const LONG,const LONG,const LONG);
  279. BOOL   Rectangle     (struct Window *,const LONG,const LONG,const LONG,const LONG);
  280. BOOL   NewCoords     (struct Window *,WORD,WORD,WORD,WORD);
  281. BOOL   DrawFrame     (struct Window *,WORD,WORD,WORD,WORD);
  282. ULONG  DrawFractal   (struct Window *,const LONG,const LONG,const LONG,const LONG);
  283. BOOL   Preview       (struct Window *,WORD,WORD);
  284. BOOL   ShowCoords    (struct Window *);
  285. VOID   RestoreCoords (VOID);
  286. VOID   SaveCoords    (VOID);
  287. BOOL   FileRequest   (struct Window *,TEXT *,TEXT *,BOOL,BOOL);
  288. BOOL   FontRequest   (struct Window *);
  289. BOOL   SMRequest     (struct ILBMInfo *);
  290. VOID   SetMenuStart  (struct Window *);
  291. VOID   SetMenuStop   (struct Window *);
  292. ULONG  ProcessMenu   (struct Window *,UWORD);
  293. VOID   ProcessMouse  (struct Window *,WORD,WORD);
  294. ULONG  HandleEvents  (struct ILBMInfo *);
  295. LONG   WinDump       (struct Window *);
  296. ULONG  Fail          (UBYTE *,ULONG);
  297. BOOL   PasteBitMap   (struct BitMap *,struct Window *,WORD,WORD);
  298. LONG   main          (ULONG,UBYTE **);
  299.  
  300. static ULONG __saveds __asm SMFilterFunc (register __a0 struct Hook *,register __a2 struct ScreenModeRequester *,register __a1 ULONG);
  301.  
  302. struct Screen *OpenIdScreen (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
  303. struct Window *OpenDisplay  (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
  304. struct BitMap *CopyBitMap   (struct Window *,WORD,WORD,WORD,WORD);
  305.  
  306. struct Hook         SMFILTERHOOK      = {NULL,NULL,(VOID *) SMFilterFunc,NULL};
  307.  
  308. struct Border       MYBORDER          = {0,0,0,0,COMPLEMENT,PAIRS,ZOOMLINE,0};
  309.  
  310. struct TextAttr     MYFONTSTRUCT      = {"topaz.font\0             ",8,FS_NORMAL,FPF_DISKFONT};
  311.  
  312. struct NewGadget    TEXTGAD           = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  313.  
  314. struct NewGadget    BUTTONGAD         = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  315.  
  316. struct NewGadget    CHECKBOXGAD       = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  317.  
  318. struct BitScaleArgs BSA               = {0,0,0,0,0,0,0,0,0,0,0,0,NULL,NULL,NULL,0,0,NULL,NULL};
  319.  
  320. struct Chunk        COPYRIGHT_CHUNK   = {NULL,ID_ILBM,ID_Copyright,IFFSIZE_UNKNOWN,"\n\n" VERSION COPYRIGHT " by " AUTHOR "\n\n"};
  321.  
  322. struct Chunk        SPECIAL_CHUNK     = {NULL,ID_ILBM,ID_MAND,sizeof (struct MandelChunk),NULL};
  323.  
  324. UWORD PENS [] = {BLACK,DARK_GREY,WHITE,WHITE,DARK_GREY,LIGHT_GREY,DARK_GREY,LIGHT_GREY,DARK_GREY,WHITE,LIGHT_GREY,DARK_GREY,(UWORD) ~0};
  325.  
  326. /*
  327.  
  328. 01    0 DETAILPEN             SFONDO
  329. 02    1 BLOCKPEN              TESTO
  330. 03    1 TEXTPEN               TESTO EVIDENZIATO
  331. 04    2 SHINEPEN              BORDI CHIARI
  332. 05    1 SHADOWPEN             BORDI SCURI
  333. 06    3 FILLPEN               BARRA TITOLO FINESTRE ATTIVE
  334. 07    1 FILLTEXTPEN           TITOLO FINESTRE ATTIVE
  335. 08    0 BACKGROUNDPEN
  336. 09    2 HIGHLIGHTTEXTPEN
  337.  
  338. 10    1 BARDETAILPEN          TESTO NEI MENU
  339. 11    2 BARBLOCKPEN           SFONDO NEI MENU
  340. 12    1 BARTRIMPEN
  341.  
  342. */
  343.  
  344. ULONG COLORS_ECS [] = {32L << 16L,
  345.                        0x00000000,0x00000000,0x00000000,
  346.                        0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
  347.                        0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,
  348.                        0x66666666,0x66666666,0x66666666,
  349.                        0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
  350.                        0xBBBBBBBB,0xBBBBBBBB,0xBBBBBBBB,
  351.                        0x77777777,0x77777777,0x77777777,
  352.                        0x33333333,0x33333333,0x33333333,
  353.                        0x33333333,0x33333333,0x00000000,
  354.                        0x77777777,0x77777777,0x00000000,
  355.                        0xBBBBBBBB,0xBBBBBBBB,0x00000000,
  356.                        0xFFFFFFFF,0xFFFFFFFF,0x00000000,
  357.                        0x00000000,0xFFFFFFFF,0x00000000,
  358.                        0x00000000,0xBBBBBBBB,0x00000000,
  359.                        0x00000000,0x77777777,0x00000000,
  360.                        0x00000000,0x33333333,0x00000000,
  361.                        0x33333333,0x00000000,0x33333333,
  362.                        0x77777777,0x00000000,0x77777777,
  363.                        0xBBBBBBBB,0x00000000,0xBBBBBBBB,
  364.                        0xFFFFFFFF,0x00000000,0xFFFFFFFF,
  365.                        0xFFFFFFFF,0x00000000,0x00000000,
  366.                        0xBBBBBBBB,0x00000000,0x00000000,
  367.                        0x77777777,0x00000000,0x00000000,
  368.                        0x33333333,0x00000000,0x00000000,
  369.                        0x00000000,0x33333333,0x33333333,
  370.                        0x00000000,0x77777777,0x77777777,
  371.                        0x00000000,0xBBBBBBBB,0xBBBBBBBB,
  372.                        0x00000000,0xFFFFFFFF,0xFFFFFFFF,
  373.                        0x00000000,0x00000000,0xFFFFFFFF,
  374.                        0x00000000,0x00000000,0xBBBBBBBB,
  375.                        0x00000000,0x00000000,0x77777777,
  376.                        0x00000000,0x00000000,0x33333333,
  377.                        NULL};
  378.  
  379. ULONG COLORS_AGA []  =  {256L << 16L,
  380.                          0x00000000,0x00000000,0x00000000, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA, 0x66666666,0x66666666,0x66666666,
  381.                          0x9f9f9f9f,0x9f9f9f9f,0x9f9f9f9f, 0xafafafaf,0xafafafaf,0xafafafaf, 0xbfbfbfbf,0xbfbfbfbf,0xbfbfbfbf, 0xcfcfcfcf,0xcfcfcfcf,0xcfcfcfcf,
  382.                          0xdfdfdfdf,0xdfdfdfdf,0xdfdfdfdf, 0xefefefef,0xefefefef,0xefefefef, 0xdfdfdfdf,0xefefefef,0xffffffff, 0xcfcfcfcf,0xdfdfdfdf,0xefefefef,
  383.                          0xbfbfbfbf,0xcfcfcfcf,0xdfdfdfdf, 0xafafafaf,0xbfbfbfbf,0xcfcfcfcf, 0x9f9f9f9f,0xafafafaf,0xbfbfbfbf, 0x8f8f8f8f,0x9f9f9f9f,0xafafafaf,
  384.                          0x7f7f7f7f,0x8f8f8f8f,0x9f9f9f9f, 0x6f6f6f6f,0x7f7f7f7f,0x8f8f8f8f, 0x5f5f5f5f,0x6f6f6f6f,0x7f7f7f7f, 0x4f4f4f4f,0x5f5f5f5f,0x6f6f6f6f,
  385.                          0x3f3f3f3f,0x4f4f4f4f,0x5f5f5f5f, 0x2f2f2f2f,0x3f3f3f3f,0x4f4f4f4f, 0x1f1f1f1f,0x2f2f2f2f,0x3f3f3f3f, 0x0f0f0f0f,0x1f1f1f1f,0x2f2f2f2f,
  386.                          0x00000000,0x0f0f0f0f,0x1f1f1f1f, 0x1f1f1f1f,0x0f0f0f0f,0x1f1f1f1f, 0x2f2f2f2f,0x1f1f1f1f,0x2f2f2f2f, 0x3f3f3f3f,0x2f2f2f2f,0x3f3f3f3f,
  387.                          0x4f4f4f4f,0x3f3f3f3f,0x4f4f4f4f, 0x5f5f5f5f,0x4f4f4f4f,0x5f5f5f5f, 0x6f6f6f6f,0x5f5f5f5f,0x6f6f6f6f, 0x7f7f7f7f,0x6f6f6f6f,0x7f7f7f7f,
  388.                          0x8f8f8f8f,0x7f7f7f7f,0x8f8f8f8f, 0x9f9f9f9f,0x8f8f8f8f,0x9f9f9f9f, 0xafafafaf,0x9f9f9f9f,0xafafafaf, 0xbfbfbfbf,0xafafafaf,0xbfbfbfbf,
  389.                          0xcfcfcfcf,0xbfbfbfbf,0xcfcfcfcf, 0xdfdfdfdf,0xcfcfcfcf,0xdfdfdfdf, 0xefefefef,0xdfdfdfdf,0xefefefef, 0xffffffff,0xefefefef,0xffffffff,
  390.                          0xefefefef,0xffffffff,0xefefefef, 0xdfdfdfdf,0xefefefef,0xdfdfdfdf, 0xcfcfcfcf,0xdfdfdfdf,0xcfcfcfcf, 0xbfbfbfbf,0xcfcfcfcf,0xbfbfbfbf,
  391.                          0xafafafaf,0xbfbfbfbf,0xafafafaf, 0x9f9f9f9f,0xafafafaf,0x9f9f9f9f, 0x8f8f8f8f,0x9f9f9f9f,0x8f8f8f8f, 0x7f7f7f7f,0x8f8f8f8f,0x7f7f7f7f,
  392.                          0x6f6f6f6f,0x7f7f7f7f,0x6f6f6f6f, 0x5f5f5f5f,0x6f6f6f6f,0x5f5f5f5f, 0x4f4f4f4f,0x5f5f5f5f,0x4f4f4f4f, 0x3f3f3f3f,0x4f4f4f4f,0x3f3f3f3f,
  393.                          0x2f2f2f2f,0x3f3f3f3f,0x2f2f2f2f, 0x1f1f1f1f,0x2f2f2f2f,0x1f1f1f1f, 0x0f0f0f0f,0x1f1f1f1f,0x0f0f0f0f, 0x0f0f0f0f,0x1f1f1f1f,0x1f1f1f1f,
  394.                          0x1f1f1f1f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x5f5f5f5f,0x5f5f5f5f,
  395.                          0x5f5f5f5f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x9f9f9f9f,0x9f9f9f9f,
  396.                          0x9f9f9f9f,0xafafafaf,0xafafafaf, 0xafafafaf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xdfdfdfdf,0xdfdfdfdf,
  397.                          0xdfdfdfdf,0xefefefef,0xefefefef, 0xefefefef,0xffffffff,0xffffffff, 0xffffffff,0xefefefef,0xefefefef, 0xefefefef,0xdfdfdfdf,0xdfdfdfdf,
  398.                          0xdfdfdfdf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xafafafaf,0xafafafaf, 0xafafafaf,0x9f9f9f9f,0x9f9f9f9f,
  399.                          0x9f9f9f9f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x5f5f5f5f,0x5f5f5f5f,
  400.                          0x5f5f5f5f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x1f1f1f1f,0x1f1f1f1f,
  401.                          0x1f1f1f1f,0x0f0f0f0f,0x0f0f0f0f, 0x1f1f1f1f,0x1f1f1f1f,0x0f0f0f0f, 0x2f2f2f2f,0x2f2f2f2f,0x1f1f1f1f, 0x3f3f3f3f,0x3f3f3f3f,0x2f2f2f2f,
  402.                          0x4f4f4f4f,0x4f4f4f4f,0x3f3f3f3f, 0x5f5f5f5f,0x5f5f5f5f,0x4f4f4f4f, 0x6f6f6f6f,0x6f6f6f6f,0x5f5f5f5f, 0x7f7f7f7f,0x7f7f7f7f,0x6f6f6f6f,
  403.                          0x8f8f8f8f,0x8f8f8f8f,0x7f7f7f7f, 0x9f9f9f9f,0x9f9f9f9f,0x8f8f8f8f, 0xafafafaf,0xafafafaf,0x9f9f9f9f, 0xbfbfbfbf,0xbfbfbfbf,0xafafafaf,
  404.                          0xcfcfcfcf,0xcfcfcfcf,0xbfbfbfbf, 0xdfdfdfdf,0xdfdfdfdf,0xcfcfcfcf, 0xefefefef,0xefefefef,0xdfdfdfdf, 0xffffffff,0xffffffff,0xefefefef,
  405.                          0xefefefef,0xefefefef,0xffffffff, 0xdfdfdfdf,0xdfdfdfdf,0xefefefef, 0xcfcfcfcf,0xcfcfcfcf,0xdfdfdfdf, 0xbfbfbfbf,0xbfbfbfbf,0xcfcfcfcf,
  406.                          0xafafafaf,0xafafafaf,0xbfbfbfbf, 0x9f9f9f9f,0x9f9f9f9f,0xafafafaf, 0x8f8f8f8f,0x8f8f8f8f,0x9f9f9f9f, 0x7f7f7f7f,0x7f7f7f7f,0x8f8f8f8f,
  407.                          0x6f6f6f6f,0x6f6f6f6f,0x7f7f7f7f, 0x5f5f5f5f,0x5f5f5f5f,0x6f6f6f6f, 0x4f4f4f4f,0x4f4f4f4f,0x5f5f5f5f, 0x3f3f3f3f,0x3f3f3f3f,0x4f4f4f4f,
  408.                          0x2f2f2f2f,0x2f2f2f2f,0x3f3f3f3f, 0x1f1f1f1f,0x1f1f1f1f,0x2f2f2f2f, 0x0f0f0f0f,0x0f0f0f0f,0x1f1f1f1f, 0x0f0f0f0f,0x0f0f0f0f,0x00000000,
  409.                          0x1f1f1f1f,0x1f1f1f1f,0x00000000, 0x2f2f2f2f,0x2f2f2f2f,0x00000000, 0x3f3f3f3f,0x3f3f3f3f,0x00000000, 0x4f4f4f4f,0x4f4f4f4f,0x00000000,
  410.                          0x5f5f5f5f,0x5f5f5f5f,0x00000000, 0x6f6f6f6f,0x6f6f6f6f,0x00000000, 0x7f7f7f7f,0x7f7f7f7f,0x00000000, 0x8f8f8f8f,0x8f8f8f8f,0x00000000,
  411.                          0x9f9f9f9f,0x9f9f9f9f,0x00000000, 0xafafafaf,0xafafafaf,0x00000000, 0xbfbfbfbf,0xbfbfbfbf,0x00000000, 0xcfcfcfcf,0xcfcfcfcf,0x00000000,
  412.                          0xdfdfdfdf,0xdfdfdfdf,0x00000000, 0xefefefef,0xefefefef,0x00000000, 0xffffffff,0xffffffff,0x00000000, 0xefefefef,0xffffffff,0x00000000,
  413.                          0xdfdfdfdf,0xffffffff,0x00000000, 0xcfcfcfcf,0xffffffff,0x00000000, 0xbfbfbfbf,0xffffffff,0x00000000, 0xafafafaf,0xffffffff,0x00000000,
  414.                          0x9f9f9f9f,0xffffffff,0x00000000, 0x8f8f8f8f,0xffffffff,0x00000000, 0x7f7f7f7f,0xffffffff,0x00000000, 0x6f6f6f6f,0xffffffff,0x00000000,
  415.                          0x5f5f5f5f,0xffffffff,0x00000000, 0x4f4f4f4f,0xffffffff,0x00000000, 0x3f3f3f3f,0xffffffff,0x00000000, 0x2f2f2f2f,0xffffffff,0x00000000,
  416.                          0x1f1f1f1f,0xffffffff,0x00000000, 0x0f0f0f0f,0xffffffff,0x00000000, 0x00000000,0xffffffff,0x00000000, 0x00000000,0xefefefef,0x00000000,
  417.                          0x00000000,0xdfdfdfdf,0x00000000, 0x00000000,0xcfcfcfcf,0x00000000, 0x00000000,0xbfbfbfbf,0x00000000, 0x00000000,0xafafafaf,0x00000000,
  418.                          0x00000000,0x9f9f9f9f,0x00000000, 0x00000000,0x8f8f8f8f,0x00000000, 0x00000000,0x7f7f7f7f,0x00000000, 0x00000000,0x6f6f6f6f,0x00000000,
  419.                          0x00000000,0x5f5f5f5f,0x00000000, 0x00000000,0x4f4f4f4f,0x00000000, 0x00000000,0x3f3f3f3f,0x00000000, 0x00000000,0x2f2f2f2f,0x00000000,
  420.                          0x00000000,0x1f1f1f1f,0x00000000, 0x00000000,0x0f0f0f0f,0x00000000, 0x0f0f0f0f,0x00000000,0x0f0f0f0f, 0x1f1f1f1f,0x00000000,0x1f1f1f1f,
  421.                          0x2f2f2f2f,0x00000000,0x2f2f2f2f, 0x3f3f3f3f,0x00000000,0x3f3f3f3f, 0x4f4f4f4f,0x00000000,0x4f4f4f4f, 0x5f5f5f5f,0x00000000,0x5f5f5f5f,
  422.                          0x6f6f6f6f,0x00000000,0x6f6f6f6f, 0x7f7f7f7f,0x00000000,0x7f7f7f7f, 0x8f8f8f8f,0x00000000,0x8f8f8f8f, 0x9f9f9f9f,0x00000000,0x9f9f9f9f,
  423.                          0xafafafaf,0x00000000,0xafafafaf, 0xbfbfbfbf,0x00000000,0xbfbfbfbf, 0xcfcfcfcf,0x00000000,0xcfcfcfcf, 0xdfdfdfdf,0x00000000,0xdfdfdfdf,
  424.                          0xefefefef,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xffffffff, 0xffffffff,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xdfdfdfdf,
  425.                          0xffffffff,0x00000000,0xcfcfcfcf, 0xffffffff,0x00000000,0xbfbfbfbf, 0xffffffff,0x00000000,0xafafafaf, 0xffffffff,0x00000000,0x9f9f9f9f,
  426.                          0xffffffff,0x00000000,0x8f8f8f8f, 0xffffffff,0x00000000,0x7f7f7f7f, 0xffffffff,0x00000000,0x6f6f6f6f, 0xffffffff,0x00000000,0x5f5f5f5f,
  427.                          0xffffffff,0x00000000,0x4f4f4f4f, 0xffffffff,0x00000000,0x3f3f3f3f, 0xffffffff,0x00000000,0x2f2f2f2f, 0xffffffff,0x00000000,0x1f1f1f1f,
  428.                          0xffffffff,0x00000000,0x0f0f0f0f, 0xffffffff,0x00000000,0x00000000, 0xefefefef,0x00000000,0x00000000, 0xdfdfdfdf,0x00000000,0x00000000,
  429.                          0xcfcfcfcf,0x00000000,0x00000000, 0xbfbfbfbf,0x00000000,0x00000000, 0xafafafaf,0x00000000,0x00000000, 0x9f9f9f9f,0x00000000,0x00000000,
  430.                          0x8f8f8f8f,0x00000000,0x00000000, 0x7f7f7f7f,0x00000000,0x00000000, 0x6f6f6f6f,0x00000000,0x00000000, 0x5f5f5f5f,0x00000000,0x00000000,
  431.                          0x4f4f4f4f,0x00000000,0x00000000, 0x3f3f3f3f,0x00000000,0x00000000, 0x2f2f2f2f,0x00000000,0x00000000, 0x1f1f1f1f,0x00000000,0x00000000,
  432.                          0x0f0f0f0f,0x00000000,0x00000000, 0x00000000,0x0f0f0f0f,0x0f0f0f0f, 0x00000000,0x1f1f1f1f,0x1f1f1f1f, 0x00000000,0x2f2f2f2f,0x2f2f2f2f,
  433.                          0x00000000,0x3f3f3f3f,0x3f3f3f3f, 0x00000000,0x4f4f4f4f,0x4f4f4f4f, 0x00000000,0x5f5f5f5f,0x5f5f5f5f, 0x00000000,0x6f6f6f6f,0x6f6f6f6f,
  434.                          0x00000000,0x7f7f7f7f,0x7f7f7f7f, 0x00000000,0x8f8f8f8f,0x8f8f8f8f, 0x00000000,0x9f9f9f9f,0x9f9f9f9f, 0x00000000,0xafafafaf,0xafafafaf,
  435.                          0x00000000,0xbfbfbfbf,0xbfbfbfbf, 0x00000000,0xcfcfcfcf,0xcfcfcfcf, 0x00000000,0xdfdfdfdf,0xdfdfdfdf, 0x00000000,0xefefefef,0xefefefef,
  436.                          0x00000000,0xffffffff,0xffffffff, 0x00000000,0xefefefef,0xffffffff, 0x00000000,0xdfdfdfdf,0xffffffff, 0x00000000,0xcfcfcfcf,0xffffffff,
  437.                          0x00000000,0xbfbfbfbf,0xffffffff, 0x00000000,0xafafafaf,0xffffffff, 0x00000000,0x9f9f9f9f,0xffffffff, 0x00000000,0x8f8f8f8f,0xffffffff,
  438.                          0x00000000,0x7f7f7f7f,0xffffffff, 0x00000000,0x6f6f6f6f,0xffffffff, 0x00000000,0x5f5f5f5f,0xffffffff, 0x00000000,0x4f4f4f4f,0xffffffff,
  439.                          0x00000000,0x3f3f3f3f,0xffffffff, 0x00000000,0x2f2f2f2f,0xffffffff, 0x00000000,0x1f1f1f1f,0xffffffff, 0x00000000,0x0f0f0f0f,0xffffffff,
  440.                          0x00000000,0x00000000,0xffffffff, 0x00000000,0x00000000,0xefefefef, 0x00000000,0x00000000,0xdfdfdfdf, 0x00000000,0x00000000,0xcfcfcfcf,
  441.                          0x00000000,0x00000000,0xbfbfbfbf, 0x00000000,0x00000000,0xafafafaf, 0x00000000,0x00000000,0x9f9f9f9f, 0x00000000,0x00000000,0x8f8f8f8f,
  442.                          0x00000000,0x00000000,0x7f7f7f7f, 0x00000000,0x00000000,0x6f6f6f6f, 0x00000000,0x00000000,0x5f5f5f5f, 0x00000000,0x00000000,0x4f4f4f4f,
  443.                          0x00000000,0x00000000,0x3f3f3f3f, 0x00000000,0x00000000,0x2f2f2f2f, 0x00000000,0x00000000,0x1f1f1f1f, 0x00000000,0x00000000,0x0f0f0f0f,
  444.                          NULL};
  445.  
  446. UWORD __chip ZoomPointer[] = {0x0000,0x0000,0x0100,0x0000,0x0100,0x0000,0x0000,0x0100,
  447.                               0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x0000,
  448.                               0xCC66,0x3C78,0x0000,0x0000,0x0100,0x0100,0x0100,0x0100,
  449.                               0x0000,0x0100,0x0000,0x0100,0x0100,0x0000,0x0100,0x0000,
  450.                               0x0000,0x0000};
  451.  
  452. struct NewMenu ProgMenu[] = { NM_TITLE,"Project",0,0,0,0,
  453.  
  454.                               NM_ITEM,"About...","A",NM_ITEMDISABLED,0,0,
  455.  
  456.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  457.  
  458.                               NM_ITEM,"Load picture...","L",NM_ITEMDISABLED,0,0,
  459.  
  460.                               NM_ITEM,"Save picture...","S",NM_ITEMDISABLED,0,0,
  461.  
  462.                               NM_ITEM,"Load palette...","K",NM_ITEMDISABLED,0,0,
  463.  
  464.                               NM_ITEM,"Save palette...","J",NM_ITEMDISABLED,0,0,
  465.  
  466.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  467.  
  468.                               NM_ITEM,"Print...","D",NM_ITEMDISABLED,0,0,
  469.  
  470.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  471.  
  472.                               NM_ITEM,"Quit...","Q",NM_ITEMDISABLED,0,0,
  473.  
  474. /***************************************************************************************/
  475.  
  476.                               NM_TITLE,"Options",0,0,0,0,
  477.  
  478.                               NM_ITEM,"Title",0,NM_ITEMDISABLED,0,0,
  479.                               NM_SUB,"Title bar","O",CHECKIT|MENUTOGGLE|CHECKED,0,0,
  480.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  481.                               NM_SUB,"Last time","T",0,0,0,
  482.  
  483.                               NM_ITEM,"Limits...","C",NM_ITEMDISABLED,0,0,
  484.  
  485.                               NM_ITEM,"Iterations",0,NM_ITEMDISABLED,0,0,
  486.                               NM_SUB,"64",0,CHECKIT,~(1<<0),0,
  487.                               NM_SUB,"128",0,CHECKIT,~(1<<1),0,
  488.                               NM_SUB,"192",0,CHECKIT,~(1<<2),0,
  489.                               NM_SUB,"256",0,CHECKIT,~(1<<3),0,
  490.                               NM_SUB,"320",0,CHECKIT|CHECKED,~(1<<4),0,
  491.                               NM_SUB,"384",0,CHECKIT,~(1<<5),0,
  492.                               NM_SUB,"448",0,CHECKIT,~(1<<6),0,
  493.                               NM_SUB,"512",0,CHECKIT,~(1<<7),0,
  494.                               NM_SUB,"1024",0,CHECKIT,~(1<<8),0,
  495.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  496.                               NM_SUB,"Custom...","I",CHECKIT,~(1<<10),0,
  497.  
  498.                               NM_ITEM,"Priority",0,0,0,0,
  499.                               NM_SUB,"-5","%",CHECKIT,~(1<<0),0,
  500.                               NM_SUB,"-4","$",CHECKIT,~(1<<1),0,
  501.                               NM_SUB,"-3","£",CHECKIT,~(1<<2),0,
  502.                               NM_SUB,"-2","\"",CHECKIT,~(1<<3),0,
  503.                               NM_SUB,"-1","!",CHECKIT,~(1<<4),0,
  504.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  505.                               NM_SUB," 0","0",CHECKIT,~(1<<6),0,
  506.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  507.                               NM_SUB,"+1","1",CHECKIT,~(1<<8),0,
  508.                               NM_SUB,"+2","2",CHECKIT,~(1<<9),0,
  509.                               NM_SUB,"+3","3",CHECKIT,~(1<<10),0,
  510.                               NM_SUB,"+4","4",CHECKIT,~(1<<11),0,
  511.                               NM_SUB,"+5","5",CHECKIT,~(1<<12),0,
  512.  
  513.                               NM_ITEM,"Color mapping",0,0,0,0,
  514.                               NM_SUB,"Repeated",0,CHECKIT,~(1<<0),0,
  515.                               NM_SUB,"Spread",0,CHECKIT|CHECKED,~(1<<1),0,
  516.  
  517.                               NM_ITEM,"Precision",0,0,0,0,
  518.                               NM_SUB,"Integer",0,CHECKIT|CHECKED,~(1<<0),0,
  519.                               NM_SUB,"Real",0,CHECKIT|NM_ITEMDISABLED,~(1<<1),0,
  520.                               NM_SUB,"Ppc",0,CHECKIT|NM_ITEMDISABLED,~(1<<2),0,
  521.  
  522. /***************************************************************************************/
  523.  
  524.                               NM_TITLE,"Calculate",0,0,0,0,
  525.  
  526.                               NM_ITEM,"PreView","W",NM_ITEMDISABLED,0,0,
  527.  
  528.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  529.  
  530.                               NM_ITEM,"ReCalculate","R",NM_ITEMDISABLED,0,0,
  531.  
  532.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  533.  
  534.                               NM_ITEM,"Undo","U",NM_ITEMDISABLED,0,0,
  535.  
  536.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  537.  
  538.                               NM_ITEM,"Zoom","Z",NM_ITEMDISABLED,0,0,
  539.  
  540.                               NM_ITEM,"Stop","X",0,0,0,
  541.  
  542. /***************************************************************************************/
  543.  
  544.                               NM_TITLE,"Video",0,0,0,0,
  545.  
  546.                               NM_ITEM,"Cycle",0,NM_ITEMDISABLED,0,0,
  547.                               NM_SUB,"Forward",">",0,0,0,
  548.                               NM_SUB,"Backward","<",0,0,0,
  549.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  550.                               NM_SUB,"Delay...","-",0,0,0,
  551.  
  552.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  553.  
  554.                               NM_ITEM,"Palette...","P",NM_ITEMDISABLED,0,0,
  555.  
  556.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  557.  
  558.                               NM_ITEM,"Screen mode...","V",NM_ITEMDISABLED,0,0,
  559.  
  560.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  561.  
  562.                               NM_ITEM,"Font settings...","F",NM_ITEMDISABLED,0,0,
  563.  
  564.                               NM_END,0,0,0,0,0 };
  565.  
  566.  
  567. struct Menu *MAINMENU = NULL;
  568.  
  569. struct BitMap *MYBITMAP = NULL;
  570.  
  571. struct Task *THISTASK = NULL;
  572.  
  573. struct TextFont *NEWFONT = NULL;
  574.  
  575. struct ILBMInfo MYILBM;
  576.  
  577. struct MandelChunk MANDChunk;
  578.  
  579. struct MandelChunk *MANDChunkTmp = NULL;
  580.  
  581. LONG IlbmProps [] = { ID_ILBM, ID_BMHD, ID_ILBM, ID_CMAP, ID_ILBM, ID_CAMG, ID_ILBM, ID_MAND, TAG_END };
  582.  
  583. LONG IlbmCollects [] = { TAG_END };
  584.  
  585. LONG IlbmStops [] = { ID_ILBM, ID_BODY, TAG_END };
  586.  
  587. IMPORT WORD __asm MandPPC (register __d0 WORD,register __fp0 long double,register __fp1 long double);
  588.  
  589. #ifdef __USE_FPU
  590.  
  591. IMPORT WORD __asm MandFPU (register __d0 WORD,register __fp0 long double,register __fp1 long double);
  592.  
  593. #endif
  594.  
  595. IMPORT WORD __asm MandINT (register __d0 WORD,register __d1 LONG,register __d2 LONG);
  596.  
  597. IMPORT BOOL ModifyPalette (struct Window *,WORD,WORD,ULONG *);
  598.  
  599. IMPORT BOOL ScalePalette (struct Window *,ULONG *,ULONG,ULONG);
  600.  
  601. IMPORT BOOL Fade (struct Window *,ULONG *,ULONG,ULONG,BOOL);
  602.  
  603. IMPORT BOOL Cycle (struct Window *,ULONG,BOOL);
  604.  
  605. IMPORT LONG QueryMandPic (struct ILBMInfo *,struct MandelChunk **,UBYTE *);
  606.  
  607. IMPORT LONG LoadMandPic (struct ILBMInfo *,UBYTE *);
  608.  
  609. IMPORT LONG SaveMandPic (struct ILBMInfo *,struct Chunk *,struct Chunk *,UBYTE *);
  610.  
  611. IMPORT LONG LoadPalette (struct ILBMInfo *,UBYTE *);
  612.  
  613. IMPORT LONG SavePalette (struct ILBMInfo *,struct Chunk *,UBYTE *);
  614.  
  615. VOID PutPointer (struct Window *Win,UWORD *PointerImage,LONG Width,LONG Height,LONG XOrigin,LONG YOrigin,UBYTE Type)
  616. {
  617.   switch (Type)
  618.   {
  619.      case CLEAR_POINTER:  SetWindowPointer (Win,TAG_END);
  620.  
  621.                           break;
  622.  
  623.      case BUSY_POINTER:   SetWindowPointer (Win,WA_BusyPointer,TRUE,TAG_END);
  624.  
  625.                           break;
  626.  
  627.      case ZOOM_POINTER:   SetPointer (Win,PointerImage,Height,Width,XOrigin,YOrigin);
  628.   }
  629. }
  630.  
  631. UBYTE GetMaxPlanes (ULONG ModeID)
  632. {
  633. DisplayInfoHandle DisplayHandle;
  634.  
  635. struct DimensionInfo DimensionInfo;
  636.  
  637. UBYTE Planes = 0;
  638.  
  639.   DisplayHandle = FindDisplayInfo (ModeID);
  640.  
  641.   if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DimensionInfo,sizeof (struct DimensionInfo),DTAG_DIMS,ModeID))
  642.   {
  643.      Planes = DimensionInfo.MaxDepth;
  644.   }
  645.  
  646.   else Fail (DimensionInfoError,20L);
  647.  
  648.   return Planes;
  649. }
  650.  
  651. LONG CheckGFX (VOID)
  652. {
  653. DisplayInfoHandle DisplayHandle;
  654.  
  655. struct DisplayInfo DisplayInfo;
  656.  
  657. BOOL AGA = FALSE,RTG = FALSE;
  658.  
  659. ULONG ModeID = (ULONG) INVALID_ID;
  660.  
  661.   if (GetMaxPlanes (LORES_KEY) == MAX_DEPTH) AGA = TRUE;
  662.  
  663.   while (((ModeID = NextDisplayInfo (ModeID)) != INVALID_ID) && RTG == FALSE)
  664.   {
  665.         DisplayHandle = FindDisplayInfo (ModeID);
  666.  
  667.         if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DisplayInfo,sizeof (struct DisplayInfo),DTAG_DISP,ModeID))
  668.         {
  669.            if ((DisplayInfo.PropertyFlags & DIPF_IS_FOREIGN) && (GetMaxPlanes (ModeID) >= MAX_DEPTH)) RTG = TRUE;
  670.         }
  671.   }
  672.  
  673.   if (RTG && AGA) return 3L;
  674.  
  675.   if (RTG) return 2L;
  676.  
  677.   if (AGA) return 1L;
  678.  
  679.   return NULL;
  680. }
  681.  
  682. BOOL CheckEHB (ULONG ModeID)
  683. {
  684. DisplayInfoHandle DisplayHandle;
  685.  
  686. struct DisplayInfo DisplayInfo;
  687.  
  688. BOOL IsEHB = FALSE;
  689.  
  690.   DisplayHandle = FindDisplayInfo (ModeID);
  691.  
  692.   if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DisplayInfo,sizeof (struct DisplayInfo),DTAG_DISP,ModeID))
  693.   {
  694.      if (DisplayInfo.PropertyFlags & DIPF_IS_EXTRAHALFBRITE) IsEHB = TRUE;
  695.   }
  696.  
  697.   else Fail (DisplayInfoError,20L);
  698.  
  699.   return IsEHB;
  700. }
  701.  
  702. ULONG CheckFPU (UWORD CpuFlags)
  703. {
  704. ULONG MCFPU = NULL, PPCFPU = NULL;
  705.  
  706.   if ((AFF_68060 & CpuFlags) || (AFF_FPU40 & CpuFlags) || (AFF_68882 & CpuFlags) || (AFF_68881 & CpuFlags)) MCFPU = FPU_68K;
  707.  
  708.   if (0) PPCFPU = FPU_PPC;    /* to be continued... */
  709.  
  710.   return (MCFPU | PPCFPU);
  711. }
  712.  
  713. VOID CloseDisplay (struct ILBMInfo *Ilbm,CPTR *VInfo)
  714. {
  715.   if (WMASK & MASK)
  716.   {
  717.      ClearMenuStrip (Ilbm->win);
  718.  
  719.      PutPointer (Ilbm->win,0,0,0,0,0,CLEAR_POINTER);
  720.  
  721.      CloseWindow (Ilbm->win);
  722.  
  723.      Ilbm->win = NULL;
  724.  
  725.      Ilbm->wrp = NULL;
  726.  
  727.      MASK ^= WMASK;
  728.   }
  729.  
  730.   if (VMASK & MASK)
  731.   {
  732.      FreeVisualInfo (VInfo);
  733.  
  734.      MASK ^= VMASK;
  735.   }
  736.  
  737.   if (SMASK & MASK)
  738.   {
  739.      CloseScreen (Ilbm->scr);
  740.  
  741.      FreeBitMap (Ilbm->brbitmap);
  742.  
  743.      Ilbm->scr = NULL;
  744.  
  745.      Ilbm->vp  = NULL;
  746.  
  747.      Ilbm->srp = NULL;
  748.  
  749.      MASK ^= SMASK;
  750.   }
  751.  
  752.   if (FMASK & MASK)
  753.   {
  754.      CloseFont (NEWFONT);
  755.  
  756.      MASK ^= FMASK;
  757.   }
  758. }
  759.  
  760. struct Window *OpenDisplay (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
  761. {
  762. struct Screen *Scr;
  763.  
  764. struct Window *Win = NULL;
  765.  
  766.   if (Scr = OpenIdScreen (Ilbm,Width,Height,Depth,ModeID))
  767.   {
  768.      Win = OpenWindowTags (NULL,
  769.                            WA_Left,Scr->LeftEdge,
  770.                            WA_Top,Scr->TopEdge,
  771.                            WA_Width,Scr->Width,
  772.                            WA_Height,Scr->Height,
  773.                            WA_ScreenTitle,VERSION,
  774.                            WA_CustomScreen,Scr,
  775.                            WA_IDCMP,IDCMP_STANDARD,
  776.                            WA_Flags,WFLG_STANDARD,
  777.                            WA_MouseQueue,1L,
  778.                            WA_BusyPointer,TRUE,
  779.                            TAG_END);
  780.  
  781.      if (! Win)
  782.      {
  783.         if (Scr) CloseScreen (Scr);
  784.  
  785.         return NULL;
  786.      }
  787.  
  788.      Ilbm->scr = Scr;
  789.  
  790.      Ilbm->win = Win;
  791.  
  792.      Ilbm->vp  = &(Scr->ViewPort);
  793.  
  794.      Ilbm->srp = &(Scr->RastPort);
  795.  
  796.      Ilbm->wrp = Win->RPort;
  797.  
  798.      Ilbm->Bmhd.w = Ilbm->win->Width;
  799.  
  800.      Ilbm->Bmhd.h = Ilbm->win->Height;
  801.  
  802.      Ilbm->Bmhd.nPlanes = Ilbm->wrp->BitMap->Depth;
  803.   }
  804.  
  805.   return (Win);
  806. }
  807.  
  808. struct Screen *OpenIdScreen (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
  809. {
  810. struct Rectangle Spos,DClip,TxtO,StdO,MaxO,UClip;
  811.  
  812. struct Rectangle *UClipp;
  813.  
  814. struct Screen *Scr;
  815.  
  816. LONG ErrorCode = NULL,TryNew;
  817.  
  818. ULONG BitMapTag,PassedTags;
  819.  
  820.   if (! Ilbm) return (NULL);
  821.  
  822.   TryNew = ((QueryOverscan (ModeID,&TxtO,OSCAN_TEXT)) && (QueryOverscan (ModeID,&StdO,OSCAN_STANDARD)) && (QueryOverscan (ModeID,&MaxO,OSCAN_MAX)));
  823.  
  824.   if (TryNew)
  825.   {
  826.      if (Ilbm->Video) Ilbm->ucliptype = OSCAN_VIDEO;
  827.  
  828.      if ((Ilbm->ucliptype) && (QueryOverscan (ModeID,&UClip,(LONG) Ilbm->ucliptype))) UClipp = &UClip;
  829.  
  830.      else UClipp = NULL;
  831.  
  832.      ClipIt (Width,Height,&Spos,&DClip,&TxtO,&StdO,&MaxO,UClipp,Ilbm->IFFPFlags & IFFPF_NOCENTER ? TRUE : FALSE);
  833.  
  834.      BitMapTag = ((Ilbm->brbitmap) && (Ilbm->stype & CUSTOMBITMAP)) ? SA_BitMap : TAG_IGNORE;
  835.  
  836.      PassedTags = Ilbm->stags ? TAG_MORE : TAG_IGNORE;
  837.  
  838.      Scr = OpenScreenTags (NULL,
  839.                            SA_DisplayID,   ModeID,
  840.                            SA_Type,        Ilbm->stype,
  841.                            SA_Top,         Spos.MinY,
  842.                            SA_Left,        Spos.MinX,
  843.                            SA_Width,       Width,
  844.                            SA_Height,      Height,
  845.                            SA_Depth,       Depth,
  846.                            SA_DClip,       &DClip,
  847.                            SA_AutoScroll,  Ilbm->Autoscroll,
  848.                            SA_Colors32,    PALETTE,
  849.                            SA_Pens,        PENS,
  850.                            SA_Interleaved, TRUE,
  851.                            SA_Font,        &MYFONTSTRUCT,
  852.                            SA_Title,       VERSION,
  853.                            SA_ErrorCode,   &ErrorCode,
  854.                            SA_ShowTitle,   Ilbm->TBState,
  855.                            BitMapTag,      Ilbm->brbitmap,
  856.                            PassedTags,     Ilbm->stags,
  857.                            TAG_END);
  858.  
  859.      if (! Scr)
  860.      {
  861.         switch (ErrorCode)
  862.         {
  863.                  case OSERR_NOMONITOR   : Fail (NoMonitor,20L);
  864.  
  865.                                           break;
  866.  
  867.                  case OSERR_NOCHIPS     : Fail (NoChips,20L);
  868.  
  869.                                           break;
  870.  
  871.                  case OSERR_NOMEM       : Fail (NoMem,20L);
  872.  
  873.                                           break;
  874.  
  875.                  case OSERR_NOCHIPMEM   : Fail (NoChipMem,20L);
  876.  
  877.                                           break;
  878.  
  879.                  case OSERR_PUBNOTUNIQUE: Fail (PubNotUnique,20L);
  880.  
  881.                                           break;
  882.  
  883.                  case OSERR_UNKNOWNMODE : Fail (UnknownMode,20L);
  884.  
  885.                                           break;
  886.  
  887.                  case OSERR_TOODEEP     : Fail (ScreenTooDeep,20L);
  888.  
  889.                                           break;
  890.  
  891.                  case OSERR_ATTACHFAIL  : Fail (AttachScreen,20L);
  892.  
  893.                                           break;
  894.  
  895.                  case OSERR_NOTAVAILABLE: Fail (ModeNotAvailableError,20L);
  896.  
  897.                                           break;
  898.  
  899.                  default                : Fail (UnknownScrError,20L);
  900.  
  901.                                           break;
  902.         }
  903.  
  904.         return NULL;
  905.      }
  906.   }
  907.  
  908.   else return NULL;
  909.  
  910.   return (Scr);
  911. }
  912.  
  913. ULONG ModeFallBack (ULONG OldModeID,WORD Width,WORD Height,WORD Depth)
  914. {
  915. struct Screen *PubScreen;
  916.  
  917. ULONG NewModeID = HIRESLACE_KEY,ModeID;
  918.  
  919.   if (PubScreen = LockPubScreen (NULL))
  920.   {
  921.      NewModeID = GetVPModeID (&(PubScreen->ViewPort));
  922.  
  923.      UnlockPubScreen (NULL,PubScreen);
  924.   }
  925.  
  926.   ModeID = BestModeID (BIDTAG_DIPFMustHave,(OldModeID & EXTRAHALFBRITE_KEY ? DIPF_IS_EXTRAHALFBRITE : 0),
  927.                        BIDTAG_NominalWidth,Width,
  928.                        BIDTAG_NominalHeight,Height,
  929.                        BIDTAG_Depth,Depth,
  930. /*                       BIDTAG_SourceID,NewModeID, */
  931.                        TAG_END);
  932.  
  933.   if (ModeID != INVALID_ID) NewModeID = ModeID;
  934.  
  935.   return (NewModeID);
  936. }
  937.  
  938. VOID ClipIt (WORD wide,WORD high,struct Rectangle *spos,struct Rectangle *dclip,struct Rectangle *txto, struct Rectangle *stdo,struct Rectangle *maxo, struct Rectangle *uclip,BOOL NoCenter)
  939. {
  940. struct Rectangle *besto;
  941.  
  942. WORD minx, maxx, miny, maxy;
  943.  
  944. WORD txtw, txth, stdw, stdh, bestw, besth;
  945.  
  946.     /* get the txt, std and max widths and heights */
  947.  
  948.     txtw = txto->MaxX - txto->MinX + 1;
  949.  
  950.     txth = txto->MaxY - txto->MinY + 1;
  951.  
  952.     stdw = stdo->MaxX - stdo->MinX + 1;
  953.  
  954.     stdh = stdo->MaxY - stdo->MinY + 1;
  955.  
  956.     if ((wide <= txtw) && (high <= txth))
  957.     {
  958.     besto = txto;
  959.  
  960.     bestw = txtw;
  961.  
  962.     besth = txth;
  963.     }
  964.  
  965.     else
  966.     {
  967.     besto = stdo;
  968.  
  969.     bestw = stdw;
  970.  
  971.     besth = stdh;
  972.     }
  973.  
  974.     if (uclip)
  975.     {
  976.     *dclip = *uclip;
  977.  
  978.         spos->MinX = uclip->MinX;
  979.  
  980.     spos->MinY = uclip->MinY;
  981.     }
  982.  
  983.     else
  984.     {
  985.     /* CENTER the screen based on best oscan prefs
  986.      * but confine dclip within max oscan limits
  987.      *
  988.      * FIX MinX first */
  989.  
  990.     spos->MinX = minx = besto->MinX - ((wide - bestw) >> 1);
  991.  
  992.     maxx = wide + minx - 1;
  993.  
  994.     if (maxx > maxo->MaxX)  maxx = maxo->MaxX;    /* too right */
  995.  
  996.     if (minx < maxo->MinX)
  997.         {
  998.         minx = maxo->MinX;    /* too left  */
  999.  
  1000.         /* if we want left edge of screen not clipped */
  1001.  
  1002.         if (NoCenter) spos->MinX = minx;
  1003.     }
  1004.  
  1005.     /* FIX MinY */
  1006.  
  1007.     spos->MinY = miny = besto->MinY - ((high - besth) >> 1);
  1008.  
  1009.     /* if lower than top of txto, move up */
  1010.  
  1011.     spos->MinY = miny = MIN (spos->MinY,txto->MinY);
  1012.  
  1013.     maxy = high + miny - 1;
  1014.  
  1015.     if (maxy > maxo->MaxY)  maxy = maxo->MaxY;    /* too down  */
  1016.  
  1017.     if (miny < maxo->MinY)
  1018.         {
  1019.        miny = maxo->MinY;    /* too up    */
  1020.  
  1021.        /* if we want top of screen not clipped */
  1022.  
  1023.        if (NoCenter) spos->MinY = miny;
  1024.         }
  1025.  
  1026.     /* SET up dclip */
  1027.  
  1028.     dclip->MinX = minx;
  1029.  
  1030.     dclip->MinY = miny;
  1031.  
  1032.     dclip->MaxX = maxx;
  1033.  
  1034.     dclip->MaxY = maxy;
  1035.     }
  1036. }
  1037.  
  1038. LONG MakeDisplay (struct ILBMInfo *Ilbm)
  1039. {
  1040. static ULONG SAVED_COMPONENT = NULL,SAVED_POSITION = NULL;
  1041.  
  1042.   if (Ilbm->IFFPFlags & IFFPF_USERMODE)    Ilbm->camg = Ilbm->usermodeid;
  1043.  
  1044.   Ilbm->Bmhd.w = MAX (MIN_WIDTH,Ilbm->Bmhd.w);
  1045.  
  1046.   Ilbm->Bmhd.h = MAX (MIN_HEIGHT,Ilbm->Bmhd.h);
  1047.  
  1048.   if (ModeNotAvailable (Ilbm->camg) || (Ilbm->IFFPFlags & IFFPF_BESTFIT))
  1049.  
  1050.      Ilbm->camg = ModeFallBack (Ilbm->camg,Ilbm->Bmhd.w,Ilbm->Bmhd.h,Ilbm->Bmhd.nPlanes);
  1051.  
  1052.   Ilbm->Bmhd.nPlanes = MAX (MIN_DEPTH,Ilbm->Bmhd.nPlanes);
  1053.  
  1054.   if (Ilbm->Bmhd.nPlanes > GetMaxPlanes (Ilbm->camg)) Ilbm->Bmhd.nPlanes = GetMaxPlanes (Ilbm->camg);
  1055.  
  1056.   if (NEWFONT = OpenDiskFont (&MYFONTSTRUCT)) MASK |= FMASK;
  1057.  
  1058.   else
  1059.   {
  1060.      strcpy (MYFONTSTRUCT.ta_Name,DEF_FONTNAME);
  1061.  
  1062.      MYFONTSTRUCT.ta_YSize = DEF_FONTSIZE;
  1063.  
  1064.      MYFONTSTRUCT.ta_Style = FS_NORMAL;
  1065.  
  1066.      MYFONTSTRUCT.ta_Flags = FPF_ROMFONT;
  1067.  
  1068.      if (NEWFONT = OpenFont (&MYFONTSTRUCT)) MASK |= FMASK;
  1069.  
  1070.      else
  1071.      {
  1072.        Fail (FontError,20L);
  1073.  
  1074.        return NULL;
  1075.      }
  1076.   }
  1077.  
  1078.   PALETTE [0L] = (Ilbm->vp->ColorMap->Count) << 16L;
  1079.  
  1080.   if (SAVED_POSITION) PALETTE [SAVED_POSITION] = SAVED_COMPONENT;
  1081.  
  1082.   SAVED_POSITION = (3L * (Ilbm->vp->ColorMap->Count)) + 1L;
  1083.  
  1084.   SAVED_COMPONENT = PALETTE [SAVED_POSITION];
  1085.  
  1086.   PALETTE [SAVED_POSITION] = NULL;
  1087.  
  1088.   if (! (OpenDisplay (Ilbm,MAX (Ilbm->Bmhd.pageWidth,Ilbm->Bmhd.w),MAX (Ilbm->Bmhd.pageHeight,Ilbm->Bmhd.h),Ilbm->Bmhd.nPlanes,Ilbm->camg))) return NULL;
  1089.  
  1090.   MASK |= SMASK;
  1091.  
  1092.   MASK |= WMASK;
  1093.  
  1094.   if (! (VINFO = GetVisualInfo (Ilbm->scr,TAG_END)))
  1095.   {
  1096.      Fail (VisualInfoError,20L);
  1097.  
  1098.      return NULL;
  1099.   }
  1100.  
  1101.   MASK |= VMASK;
  1102.  
  1103.   if (! (LayoutMenus (MAINMENU,VINFO,GTMN_TextAttr,&MYFONTSTRUCT,GTMN_NewLookMenus,TRUE,TAG_END)))
  1104.   {
  1105.      Fail (FontError,20L);
  1106.  
  1107.      return NULL;
  1108.   }
  1109.  
  1110.   SetMenuStrip (Ilbm->win,MAINMENU);
  1111.  
  1112.   Ilbm->EHB = CheckEHB (Ilbm->camg);
  1113.  
  1114.   return (Ilbm->vp->ColorMap->Count);
  1115. }
  1116.  
  1117. VOID ShowTime (struct Window *Win,TEXT *String,ULONG Secs)
  1118. {
  1119.   sprintf (BAR_STRING,"%s %uh %um %us - Average speed: %.3lf Pix/sec",String,Secs / 3600L,(Secs / 60L) % 60L,Secs % 60L,(DOUBLE) ((Win->Width - Win->LeftEdge) * (Win->Height - Win->TopEdge)) / (DOUBLE) Secs);
  1120.  
  1121.   SetWindowTitles (Win,(TEXT *) ~0,BAR_STRING);
  1122. }
  1123.  
  1124. VOID SaveCoords (VOID)
  1125. {
  1126.   URMIN = RMIN;
  1127.  
  1128.   URMAX = RMAX;
  1129.  
  1130.   UIMIN = IMIN;
  1131.  
  1132.   UIMAX = IMAX;
  1133. }
  1134.  
  1135. VOID RestoreCoords (VOID)
  1136. {
  1137.   RMIN = URMIN;
  1138.  
  1139.   RMAX = URMAX;
  1140.  
  1141.   IMIN = UIMIN;
  1142.  
  1143.   IMAX = UIMAX;
  1144. }
  1145.  
  1146. BOOL NewCoords (struct Window *Win,WORD a1,WORD b1,WORD a2,WORD b2)
  1147. {
  1148. long double KReal,KImag;
  1149.  
  1150.   if (((a2 - a1) < 2L) || ((b2 - b1) < 2L)) return FALSE;
  1151.  
  1152.   KReal = fabs (RMAX-RMIN) / ((long double) Win->Width);
  1153.  
  1154.   KImag = fabs (IMAX-IMIN) / ((long double) Win->Height);
  1155.  
  1156.   SaveCoords ();
  1157.  
  1158.   RMAX = RMIN + ((long double) a2 * KReal);
  1159.  
  1160.   IMIN = IMAX - ((long double) b2 * KImag);
  1161.  
  1162.   RMIN += ((long double) a1 * KReal);
  1163.  
  1164.   IMAX -= ((long double) b1 * KImag);
  1165.  
  1166.   return TRUE;
  1167. }
  1168.  
  1169. VOID AdjustRatio (long double *RMin,long double *IMax,long double *RMax,long double *IMin,WORD ScrWidth,WORD ScrHeight,BOOL KeepReal)
  1170. {
  1171. long double RWidth,IHeight,RCenter,ICenter;
  1172.  
  1173.   IHeight = *IMax - *IMin;
  1174.  
  1175.   RWidth  = *RMax - *RMin;
  1176.  
  1177.   if (KeepReal)
  1178.   {
  1179.      ICenter = *IMin + (IHeight / 2.0);
  1180.  
  1181.      IHeight = (RWidth * ScrHeight) / ScrWidth;
  1182.  
  1183.      *IMax = ICenter + (IHeight / 2.0);
  1184.  
  1185.      *IMin = ICenter - (IHeight / 2.0);
  1186.   }
  1187.  
  1188.   else
  1189.   {
  1190.      RCenter = *RMin + (RWidth / 2.0);
  1191.  
  1192.      RWidth = (IHeight * ScrWidth) / ScrHeight;
  1193.  
  1194.      *RMax = RCenter + (RWidth / 2.0);
  1195.  
  1196.      *RMin = RCenter - (RWidth / 2.0);
  1197.   }
  1198. }
  1199.  
  1200. LONG About (struct Window *Win)
  1201. {
  1202. static struct EasyStruct MyReq_1 = { sizeof (struct EasyStruct),0,"Informations requester","  " VERSION COPYRIGHT "\n\n\n  Snail address:" "\n\n  " AUTHOR "\n  " ADDRESS "\n\n\n  " EMAIL "\n\n  This program is GiftWare!  \n\n","Ok|More..." };
  1203.  
  1204. static struct EasyStruct MyReq_2 = { sizeof (struct EasyStruct),0,"Workgroup","Greetings & thanks in alphabetical order:\n\n  Claudio Pucci\n  Giuseppe Staffelli\n  Sergio Tassi\n\n\nIf someone hasn't the courage to risk\nfor his ideals, either his ideals are\nworth nothing, or worth nothing is he\n\nAmiga forever.\n\n","Ok" };
  1205.  
  1206. LONG More;
  1207.  
  1208.   More = EasyRequest (Win,&MyReq_1,0);
  1209.  
  1210.   if (! More) EasyRequest (Win,&MyReq_2,0);
  1211.  
  1212.   return More;
  1213. }
  1214.  
  1215. LONG Choice (struct Window *Win,TEXT *Title,TEXT *String)
  1216. {
  1217. struct EasyStruct MyReq = { sizeof (struct EasyStruct),NULL,0,0,"Yes|No" };
  1218.  
  1219.   MyReq.es_Title = Title;
  1220.  
  1221.   MyReq.es_TextFormat = String;
  1222.  
  1223.   return EasyRequest (Win,&MyReq,0);
  1224. }
  1225.  
  1226. BOOL ShowCoords (struct Window *Win)
  1227. {
  1228. struct Gadget *GadList = NULL,*StringGad_1,*StringGad_2,*StringGad_3,*StringGad_4;
  1229.  
  1230. struct Gadget *MyButtonGad,*MyCheckBoxGad,*MyGad;
  1231.  
  1232. struct Window *GadWin;
  1233.  
  1234. struct IntuiMessage *Message;
  1235.  
  1236. BOOL NewLimits = FALSE,Exit = FALSE,Accept = FALSE,Reset = FALSE,Ratio = FALSE,KeepReal = TRUE;
  1237.  
  1238. TEXT String [MAXCHARS];
  1239.  
  1240. UWORD MyCode;
  1241.  
  1242. ULONG MyClass;
  1243.  
  1244. long double Tmp_RMIN = RMIN,Tmp_IMAX = IMAX,Tmp_RMAX = RMAX,Tmp_IMIN = IMIN;
  1245.  
  1246.   TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = CHECKBOXGAD.ng_VisualInfo  = VINFO;
  1247.  
  1248.   StringGad_1 = CreateContext (&GadList);
  1249.  
  1250.   TEXTGAD.ng_LeftEdge     = 118;
  1251.  
  1252.   TEXTGAD.ng_TopEdge      = 20;
  1253.  
  1254.   TEXTGAD.ng_Width        = 194;
  1255.  
  1256.   TEXTGAD.ng_Height       = (MYFONTSTRUCT.ta_YSize * 3L) >> 1L;
  1257.  
  1258.   TEXTGAD.ng_GadgetText   = "_Left";
  1259.  
  1260.   TEXTGAD.ng_Flags        = PLACETEXT_LEFT;
  1261.  
  1262.   sprintf (String,"%+2.16lf",RMIN);
  1263.  
  1264.   StringGad_1 = CreateGadget (STRING_KIND,StringGad_1,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1265.  
  1266.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1267.  
  1268.   TEXTGAD.ng_GadgetText   = "_Top ";
  1269.  
  1270.   sprintf (String,"%+2.16lf",IMAX);
  1271.  
  1272.   StringGad_2 = CreateGadget (STRING_KIND,StringGad_1,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1273.  
  1274.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1275.  
  1276.   TEXTGAD.ng_GadgetText   = "_Right";
  1277.  
  1278.   TEXTGAD.ng_Flags        = PLACETEXT_RIGHT;
  1279.  
  1280.   sprintf (String,"%+2.16lf",RMAX);
  1281.  
  1282.   StringGad_3 = CreateGadget (STRING_KIND,StringGad_2,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1283.  
  1284.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1285.  
  1286.   TEXTGAD.ng_GadgetText   = "_Bottom";
  1287.  
  1288.   sprintf (String,"%+2.16lf",IMIN);
  1289.  
  1290.   StringGad_4 = CreateGadget (STRING_KIND,StringGad_3,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1291.  
  1292.   CHECKBOXGAD.ng_LeftEdge   = 14;
  1293.  
  1294.   CHECKBOXGAD.ng_TopEdge    = TEXTGAD.ng_TopEdge + TEXTGAD.ng_Height + 14;;
  1295.  
  1296.   CHECKBOXGAD.ng_Width      = MYFONTSTRUCT.ta_YSize << 1L;
  1297.  
  1298.   CHECKBOXGAD.ng_Height     = MYFONTSTRUCT.ta_YSize + 6;
  1299.  
  1300.   CHECKBOXGAD.ng_GadgetText = "_Keep X axis for ratio";
  1301.  
  1302.   CHECKBOXGAD.ng_Flags      = PLACETEXT_RIGHT;
  1303.  
  1304.   CHECKBOXGAD.ng_GadgetID   = KEEP;
  1305.  
  1306.   MyCheckBoxGad = CreateGadget (CHECKBOX_KIND,StringGad_4,&CHECKBOXGAD,GTCB_Checked,TRUE,GTCB_Scaled,TRUE,GT_Underscore,'_',TAG_END);
  1307.  
  1308.   BUTTONGAD.ng_LeftEdge   = 14;
  1309.  
  1310.   BUTTONGAD.ng_TopEdge    = CHECKBOXGAD.ng_TopEdge + CHECKBOXGAD.ng_Height + 30;
  1311.  
  1312.   BUTTONGAD.ng_Width      = 90;
  1313.  
  1314.   BUTTONGAD.ng_Height     = (MYFONTSTRUCT.ta_YSize * 3L) >> 1L;
  1315.  
  1316.   BUTTONGAD.ng_GadgetText = "_Accept";
  1317.  
  1318.   BUTTONGAD.ng_GadgetID   = ACCEPT;
  1319.  
  1320.   MyButtonGad = CreateGadget (BUTTON_KIND,MyCheckBoxGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1321.  
  1322.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1323.  
  1324.   BUTTONGAD.ng_GadgetText = "Rat_io";
  1325.  
  1326.   BUTTONGAD.ng_GadgetID   = RATIO;
  1327.  
  1328.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1329.  
  1330.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1331.  
  1332.   BUTTONGAD.ng_GadgetText = "Re_set";
  1333.  
  1334.   BUTTONGAD.ng_GadgetID   = RESET;
  1335.  
  1336.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1337.  
  1338.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1339.  
  1340.   BUTTONGAD.ng_GadgetText = "_Cancel";
  1341.  
  1342.   BUTTONGAD.ng_GadgetID   = CANCEL;
  1343.  
  1344.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1345.  
  1346.   if (MyButtonGad)
  1347.   {
  1348.      GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 25,
  1349.                                    WA_Top,Win->TopEdge + 35,
  1350.                                    WA_Width,BUTTONGAD.ng_LeftEdge + BUTTONGAD.ng_Width + 24,
  1351.                                    WA_Height,BUTTONGAD.ng_TopEdge + BUTTONGAD.ng_Height + 35,
  1352.                                    WA_Title,"Coordinates requester",
  1353.                                    WA_ScreenTitle,"Insert new range...",
  1354.                                    WA_CustomScreen,Win->WScreen,
  1355.                                    WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|STRINGIDCMP|BUTTONIDCMP,
  1356.                                    WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
  1357.                                    WA_Gadgets,GadList,
  1358.                                    TAG_END);
  1359.      if (GadWin)
  1360.      {
  1361.         GT_RefreshWindow (GadWin,NULL);
  1362.  
  1363.         do {  WaitPort (GadWin->UserPort);
  1364.  
  1365.               if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
  1366.               {
  1367.                      MyGad = (struct Gadget *) Message->IAddress;
  1368.  
  1369.                      MyClass = Message->Class;
  1370.  
  1371.                      MyCode = Message->Code;
  1372.  
  1373.                      GT_ReplyIMsg ((struct IntuiMessage *) Message);
  1374.  
  1375.                      switch (MyClass)
  1376.                      {
  1377.                             case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
  1378.  
  1379.                                                        GT_EndRefresh (GadWin,TRUE);
  1380.  
  1381.                                                        break;
  1382.  
  1383.                             case IDCMP_VANILLAKEY    : switch (ToUpper ((ULONG) MyCode))
  1384.                                                        {
  1385.                                                               case 'L' : ActivateGadget (StringGad_1,GadWin,0);
  1386.  
  1387.                                                                          break;
  1388.  
  1389.                                                               case 'T' : ActivateGadget (StringGad_2,GadWin,0);
  1390.  
  1391.                                                                          break;
  1392.  
  1393.                                                               case 'R' : ActivateGadget (StringGad_3,GadWin,0);
  1394.  
  1395.                                                                          break;
  1396.  
  1397.                                                               case 'B' : ActivateGadget (StringGad_4,GadWin,0);
  1398.  
  1399.                                                                          break;
  1400.  
  1401.                                                               case 'A' : Accept = TRUE;
  1402.  
  1403.                                                                          break;
  1404.  
  1405.                                                               case 'I' : Ratio = TRUE;
  1406.  
  1407.                                                                          break;
  1408.  
  1409.                                                               case 'S' : Reset = TRUE;
  1410.  
  1411.                                                                          break;
  1412.  
  1413.                                                               case 'C' : Exit = TRUE;
  1414.  
  1415.                                                                          break;
  1416.  
  1417.                                                               case 'K' : KeepReal = ! KeepReal;
  1418.  
  1419.                                                                          GT_SetGadgetAttrs (MyCheckBoxGad,GadWin,NULL,GTCB_Checked,KeepReal,TAG_END);
  1420.  
  1421.                                                                          break;
  1422.  
  1423.                                                            case VAN_ESC: Exit = TRUE;
  1424.                                                        }
  1425.  
  1426.                                                                break;
  1427.  
  1428.                             case IDCMP_GADGETUP      : switch (MyGad->GadgetID)
  1429.                                                        {
  1430.                                                               case ACCEPT:   Accept = TRUE;
  1431.  
  1432.                                                                              break;
  1433.  
  1434.                                                               case  RATIO:   Ratio = TRUE;
  1435.  
  1436.                                                                              break;
  1437.  
  1438.                                                               case  RESET:   Reset = TRUE;
  1439.  
  1440.                                                                              break;
  1441.  
  1442.                                                               case   KEEP:   KeepReal = ! KeepReal;
  1443.  
  1444.                                                                              break;
  1445.  
  1446.                                                               case CANCEL:   Exit = TRUE;
  1447.                                                        }
  1448.  
  1449.                                                        break;
  1450.  
  1451.                             case IDCMP_CLOSEWINDOW   : Exit = TRUE;
  1452.                      }
  1453.  
  1454.                      if (Accept)
  1455.                      {
  1456.                         sscanf (((struct StringInfo *) StringGad_1->SpecialInfo)->Buffer,"%lf",&Tmp_RMIN);
  1457.  
  1458.                         sscanf (((struct StringInfo *) StringGad_2->SpecialInfo)->Buffer,"%lf",&Tmp_IMAX);
  1459.  
  1460.                         sscanf (((struct StringInfo *) StringGad_3->SpecialInfo)->Buffer,"%lf",&Tmp_RMAX);
  1461.  
  1462.                         sscanf (((struct StringInfo *) StringGad_4->SpecialInfo)->Buffer,"%lf",&Tmp_IMIN);
  1463.  
  1464.                         if ((Tmp_RMIN >= Tmp_RMAX) || (Tmp_IMIN >= Tmp_IMAX)) DisplayBeep (Win->WScreen);
  1465.  
  1466.                         else
  1467.                         {
  1468.                            NewLimits = Exit = TRUE;
  1469.  
  1470.                            SaveCoords ();
  1471.  
  1472.                            RMIN  = Tmp_RMIN;
  1473.  
  1474.                            IMAX  = Tmp_IMAX;
  1475.  
  1476.                            RMAX  = Tmp_RMAX;
  1477.  
  1478.                            IMIN  = Tmp_IMIN;
  1479.                         }
  1480.  
  1481.                         Accept = FALSE;
  1482.                      }
  1483.  
  1484.                      if (Ratio)
  1485.                      {
  1486.                         AdjustRatio (&Tmp_RMIN,&Tmp_IMAX,&Tmp_RMAX,&Tmp_IMIN,Win->Width,Win->Height,KeepReal);
  1487.  
  1488.                         TEXTGAD.ng_Flags = PLACETEXT_LEFT;
  1489.  
  1490.                         sprintf (String,"%+2.16lf",Tmp_RMIN);
  1491.  
  1492.                         GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
  1493.  
  1494.                         sprintf (String,"%+2.16lf",Tmp_IMAX);
  1495.  
  1496.                         GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
  1497.  
  1498.                         sprintf (String,"%+2.16lf",Tmp_RMAX);
  1499.  
  1500.                         TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
  1501.  
  1502.                         GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
  1503.  
  1504.                         sprintf (String,"%+2.16lf",Tmp_IMIN);
  1505.  
  1506.                         GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
  1507.  
  1508.                         Ratio = FALSE;
  1509.                      }
  1510.  
  1511.                      if (Reset)
  1512.                      {
  1513.                         TEXTGAD.ng_Flags = PLACETEXT_LEFT;
  1514.  
  1515.                         sprintf (String,"%+2.16lf",DEF_RMIN);
  1516.  
  1517.                         GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
  1518.  
  1519.                         sprintf (String,"%+2.16lf",DEF_IMAX);
  1520.  
  1521.                         GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
  1522.  
  1523.                         TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
  1524.  
  1525.                         sprintf (String,"%+2.16lf",DEF_RMAX);
  1526.  
  1527.                         GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
  1528.  
  1529.                         sprintf (String,"%+2.16lf",DEF_IMIN);
  1530.  
  1531.                         GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
  1532.  
  1533.                         Reset = FALSE;
  1534.                      }
  1535.               }
  1536.  
  1537.            } while (Exit == FALSE);
  1538.  
  1539.        CloseWindow (GadWin);
  1540.      }
  1541.  
  1542.      else Fail (WindowGadgetError,15L);
  1543.   }
  1544.  
  1545.   else Fail (GadgetError,15L);
  1546.  
  1547.   FreeGadgets (GadList);
  1548.  
  1549.   return NewLimits;
  1550. }
  1551.  
  1552. ULONG IntegerGad (struct Window *Win,TEXT *TitleWin,TEXT *TitleScr,TEXT *TxtString,ULONG Var)
  1553. {
  1554. struct IntuiMessage *Message;
  1555.  
  1556. struct Gadget *GadList = NULL,*MyIntGad,*MyButtonGad,*MyGad;
  1557.  
  1558. struct Window *GadWin;
  1559.  
  1560. BOOL Exit = FALSE;
  1561.  
  1562. UWORD MyCode;
  1563.  
  1564. ULONG MyClass;
  1565.  
  1566.   TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = VINFO;
  1567.  
  1568.   MyIntGad = CreateContext (&GadList);
  1569.  
  1570.   TEXTGAD.ng_LeftEdge     = 170;
  1571.  
  1572.   TEXTGAD.ng_TopEdge      = 20;
  1573.  
  1574.   TEXTGAD.ng_Width        = 90;
  1575.  
  1576.   TEXTGAD.ng_Height       = (MYFONTSTRUCT.ta_YSize * 3L) >> 1L;
  1577.  
  1578.   TEXTGAD.ng_GadgetText   = TxtString;
  1579.  
  1580.   TEXTGAD.ng_Flags        = PLACETEXT_LEFT;
  1581.  
  1582.   MyIntGad = CreateGadget (INTEGER_KIND,MyIntGad,&TEXTGAD,GTIN_Number,Var,GTIN_MaxChars,6,STRINGA_ReplaceMode,TRUE,GT_Underscore,'_',TAG_END);
  1583.  
  1584.   BUTTONGAD.ng_LeftEdge   = 20;
  1585.  
  1586.   BUTTONGAD.ng_TopEdge    = TEXTGAD.ng_TopEdge + TEXTGAD.ng_Height + 30;
  1587.  
  1588.   BUTTONGAD.ng_Width      = 90;
  1589.  
  1590.   BUTTONGAD.ng_Height     = (MYFONTSTRUCT.ta_YSize * 3L) >> 1L;
  1591.  
  1592.   BUTTONGAD.ng_GadgetText = "_Accept";
  1593.  
  1594.   BUTTONGAD.ng_GadgetID   = ACCEPT;
  1595.  
  1596.   MyButtonGad = CreateGadget (BUTTON_KIND,MyIntGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1597.  
  1598.   BUTTONGAD.ng_LeftEdge  += (60 + BUTTONGAD.ng_Width);
  1599.  
  1600.   BUTTONGAD.ng_GadgetText = "_Cancel";
  1601.  
  1602.   BUTTONGAD.ng_GadgetID   = CANCEL;
  1603.  
  1604.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1605.  
  1606.   if (MyButtonGad)
  1607.   {
  1608.      GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 25,
  1609.                                    WA_Top,Win->TopEdge + 35,
  1610.                                    WA_Width,BUTTONGAD.ng_LeftEdge + BUTTONGAD.ng_Width + 30,
  1611.                                    WA_Height,BUTTONGAD.ng_TopEdge + BUTTONGAD.ng_Height + 35,
  1612.                                    WA_Title,TitleWin,
  1613.                                    WA_ScreenTitle,TitleScr,
  1614.                                    WA_CustomScreen,Win->WScreen,
  1615.                                    WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|INTEGERIDCMP|BUTTONIDCMP,
  1616.                                    WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
  1617.                                    WA_Gadgets,GadList,
  1618.                                    TAG_END);
  1619.  
  1620.      if (GadWin)
  1621.      {
  1622.         GT_RefreshWindow (GadWin,NULL);
  1623.  
  1624.         do {  WaitPort (GadWin->UserPort);
  1625.  
  1626.               if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
  1627.               {
  1628.                      MyGad = (struct Gadget *) Message->IAddress;
  1629.  
  1630.                      MyClass = Message->Class;
  1631.  
  1632.                      MyCode = Message->Code;
  1633.  
  1634.                      GT_ReplyIMsg ((struct IntuiMessage *) Message);
  1635.  
  1636.                      switch (MyClass)
  1637.                      {
  1638.                             case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
  1639.  
  1640.                                                        GT_EndRefresh (GadWin,TRUE);
  1641.  
  1642.                                                        break;
  1643.  
  1644.                             case IDCMP_VANILLAKEY    : switch (ToUpper ((ULONG) MyCode))
  1645.                                                        {
  1646.                                                               case 'D' :
  1647.  
  1648.                                                               case 'I' : ActivateGadget (MyIntGad,GadWin,0);
  1649.  
  1650.                                                                          break;
  1651.  
  1652.                                                               case 'A' : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
  1653.  
  1654.                                                                          Exit = TRUE;
  1655.  
  1656.                                                                          break;
  1657.  
  1658.                                                               case 'C' : Exit = TRUE;
  1659.  
  1660.                                                                          break;
  1661.  
  1662.                                                            case VAN_ESC: Exit = TRUE;
  1663.                                                        }
  1664.  
  1665.                                                        break;
  1666.  
  1667.                             case IDCMP_GADGETUP      : switch (MyGad->GadgetID)
  1668.                                                        {
  1669.                                                                case ACCEPT  : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
  1670.  
  1671.                                                                               Exit = TRUE;
  1672.  
  1673.                                                                               break;
  1674.  
  1675.                                                                case CANCEL  : Exit = TRUE;
  1676.                                                        }
  1677.  
  1678.                                                        break;
  1679.  
  1680.                             case IDCMP_CLOSEWINDOW   : Exit = TRUE;
  1681.                      }
  1682.               }
  1683.  
  1684.            } while (Exit == FALSE);
  1685.  
  1686.         CloseWindow (GadWin);
  1687.      }
  1688.  
  1689.      else Fail (WindowError,15L);
  1690.   }
  1691.  
  1692.   else Fail (GadgetError,15L);
  1693.  
  1694.   FreeGadgets (GadList);
  1695.  
  1696.   return Var;
  1697. }
  1698.  
  1699. WORD Ppc (WORD Iterazioni,long double Cre,long double Cim)
  1700. {
  1701. WORD Val;
  1702.  
  1703.   /* call Warp pre context switch */
  1704.  
  1705.   Val = MandPPC (Iterazioni,Cre,Cim);
  1706.  
  1707.   /* call Warp post context switch */
  1708.  
  1709.   return Val;
  1710. }
  1711.  
  1712. #ifdef __USE_FPU
  1713.  
  1714. WORD Real (WORD Iterazioni,long double Cre,long double Cim)
  1715. {
  1716.   return MandFPU (Iterazioni,Cre,Cim);
  1717. }
  1718.  
  1719. #else
  1720.  
  1721. WORD Real (WORD Iterazioni,long double Cre,long double Cim)
  1722. {
  1723. register long double zr,zi,zi2,dist,maxdist;
  1724.  
  1725.   zi = Cim;
  1726.  
  1727.   zr = Cre;
  1728.  
  1729.   maxdist = 4;
  1730.  
  1731.   do {
  1732.        zi2 = zi;
  1733.  
  1734.        zi *= zr;
  1735.  
  1736.        zr *= zr;
  1737.  
  1738.        zi2 *= zi2;
  1739.  
  1740.        dist = zr;
  1741.  
  1742.        dist += zi2;
  1743.  
  1744.        if (dist > maxdist) return Iterazioni;
  1745.  
  1746.        zi += zi;
  1747.  
  1748.        zr -= zi2;
  1749.  
  1750.        zi += Cim;
  1751.  
  1752.        zr += Cre;
  1753.  
  1754.      } while (-- Iterazioni);
  1755.  
  1756.   return 0;
  1757. }
  1758.  
  1759. #endif
  1760.  
  1761. WORD Integer (WORD Iterazioni,long double Cre,long double Cim)
  1762. {
  1763.   return MandINT (Iterazioni,(LONG) (Cre * MAX_POT),(LONG) (Cim * MAX_POT));
  1764. }
  1765.  
  1766. VOID VLine_R_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1767. {
  1768. REGISTER LONG y;
  1769.  
  1770. ULONG Color;
  1771.  
  1772.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1773.  
  1774.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1775.  
  1776.  for (y = b2; y >= b1; y--)
  1777.  {
  1778.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1779.  
  1780.      if (Color)
  1781.      {
  1782.         Color %= 56L,
  1783.  
  1784.         Color += ((Color > 27L) ? (RESERVED_PENS << 1L) : RESERVED_PENS);
  1785.      }
  1786.  
  1787.      SetAPen (Rp,Color);
  1788.  
  1789.      WritePixel (Rp,x,y);
  1790.  
  1791.      CIM += INCREMIMAG;
  1792.  }
  1793. }
  1794.  
  1795. VOID HLine_R_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1796. {
  1797. REGISTER LONG x;
  1798.  
  1799. ULONG Color;
  1800.  
  1801.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1802.  
  1803.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1804.  
  1805.  for (x = a1; x <= a2; x++)
  1806.  {
  1807.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1808.  
  1809.      if (Color)
  1810.      {
  1811.         Color %= 56L,
  1812.  
  1813.         Color += ((Color > 27L) ? (RESERVED_PENS << 1L) : RESERVED_PENS);
  1814.      }
  1815.  
  1816.      SetAPen (Rp,Color);
  1817.  
  1818.      WritePixel (Rp,x,y);
  1819.  
  1820.      CRE += INCREMREAL;
  1821.  }
  1822. }
  1823.  
  1824. VOID VLine_R (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1825. {
  1826. REGISTER LONG y;
  1827.  
  1828. ULONG Color;
  1829.  
  1830.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1831.  
  1832.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1833.  
  1834.  for (y = b2; y >= b1; y--)
  1835.  {
  1836.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1837.  
  1838.      if (Color)
  1839.      {
  1840.         Color %= CURRENT_MAX_COLORS,
  1841.  
  1842.         Color += RESERVED_PENS;
  1843.      }
  1844.  
  1845.      SetAPen (Rp,Color);
  1846.  
  1847.      WritePixel (Rp,x,y);
  1848.  
  1849.      CIM += INCREMIMAG;
  1850.  }
  1851. }
  1852.  
  1853. VOID HLine_R (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1854. {
  1855. REGISTER LONG x;
  1856.  
  1857. ULONG Color;
  1858.  
  1859.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1860.  
  1861.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1862.  
  1863.  for (x = a1; x <= a2; x++)
  1864.  {
  1865.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1866.  
  1867.      if (Color)
  1868.      {
  1869.         Color %= CURRENT_MAX_COLORS,
  1870.  
  1871.         Color += RESERVED_PENS;
  1872.      }
  1873.  
  1874.      SetAPen (Rp,Color);
  1875.  
  1876.      WritePixel (Rp,x,y);
  1877.  
  1878.      CRE += INCREMREAL;
  1879.  }
  1880. }
  1881.  
  1882. VOID VLine_S_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1883. {
  1884. REGISTER LONG y;
  1885.  
  1886. ULONG Color;
  1887.  
  1888.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1889.  
  1890.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1891.  
  1892.  for (y = b2; y >= b1; y--)
  1893.  {
  1894.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1895.  
  1896.      if (Color)
  1897.      {
  1898.         Color *= 56L,
  1899.  
  1900.         Color /= ITERATIONS,
  1901.  
  1902.         Color += ((Color > 27L) ? (RESERVED_PENS << 1L) : RESERVED_PENS);
  1903.      }
  1904.  
  1905.      SetAPen (Rp,Color);
  1906.  
  1907.      WritePixel (Rp,x,y);
  1908.  
  1909.      CIM += INCREMIMAG;
  1910.  }
  1911. }
  1912.  
  1913. VOID HLine_S_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1914. {
  1915. REGISTER LONG x;
  1916.  
  1917. ULONG Color;
  1918.  
  1919.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1920.  
  1921.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1922.  
  1923.  for (x = a1; x <= a2; x++)
  1924.  {
  1925.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1926.  
  1927.      if (Color)
  1928.      {
  1929.         Color *= 56L,
  1930.  
  1931.         Color /= ITERATIONS,
  1932.  
  1933.         Color += ((Color > 27L) ? (RESERVED_PENS << 1L) : RESERVED_PENS);
  1934.      }
  1935.  
  1936.      SetAPen (Rp,Color);
  1937.  
  1938.      WritePixel (Rp,x,y);
  1939.  
  1940.      CRE += INCREMREAL;
  1941.  }
  1942. }
  1943.  
  1944. VOID VLine_S (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1945. {
  1946. REGISTER LONG y;
  1947.  
  1948. ULONG Color;
  1949.  
  1950.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1951.  
  1952.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1953.  
  1954.  for (y = b2; y >= b1; y--)
  1955.  {
  1956.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1957.  
  1958.      if (Color)
  1959.      {
  1960.         Color *= CURRENT_MAX_COLORS,
  1961.  
  1962.         Color /= ITERATIONS,
  1963.  
  1964.         Color += RESERVED_PENS;
  1965.      }
  1966.  
  1967.      SetAPen (Rp,Color);
  1968.  
  1969.      WritePixel (Rp,x,y);
  1970.  
  1971.      CIM += INCREMIMAG;
  1972.  }
  1973. }
  1974.  
  1975. VOID HLine_S (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1976. {
  1977. REGISTER LONG x;
  1978.  
  1979. ULONG Color;
  1980.  
  1981.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1982.  
  1983.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1984.  
  1985.  for (x = a1; x <= a2; x++)
  1986.  {
  1987.      Color = (*FUNCTION) (MAX_ITERATIONS,CRE,CIM);
  1988.  
  1989.      if (Color)
  1990.      {
  1991.         Color *= CURRENT_MAX_COLORS,
  1992.  
  1993.         Color /= ITERATIONS,
  1994.  
  1995.         Color += RESERVED_PENS;
  1996.      }
  1997.  
  1998.      SetAPen (Rp,Color);
  1999.  
  2000.      WritePixel (Rp,x,y);
  2001.  
  2002.      CRE += INCREMREAL;
  2003.  }
  2004. }
  2005.  
  2006. BOOL CheckBox (struct RastPort *Rp,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  2007. {
  2008. const LONG Color = ReadPixel (Rp,a1,b1);
  2009.  
  2010. REGISTER LONG Var;
  2011.  
  2012.   if (Color != ReadPixel (Rp,a2,b2)) return FALSE;
  2013.  
  2014.   if (Color != ReadPixel (Rp,a2,b1)) return FALSE;
  2015.  
  2016.   if (Color != ReadPixel (Rp,a1,b2)) return FALSE;
  2017.  
  2018.   for (Var = (a1 + 1L); Var <= (a2 - 1L); Var++)
  2019.   {
  2020.       if (Color != ReadPixel (Rp,Var,b1)) return FALSE;
  2021.  
  2022.       if (Color != ReadPixel (Rp,Var,b2)) return FALSE;
  2023.   }
  2024.  
  2025.   for (Var = (b1 + 1L); Var <= (b2 - 1L); Var++)
  2026.   {
  2027.       if (Color != ReadPixel (Rp,a1,Var)) return FALSE;
  2028.  
  2029.       if (Color != ReadPixel (Rp,a2,Var)) return FALSE;
  2030.   }
  2031.  
  2032.   return TRUE;
  2033. }
  2034.  
  2035. BOOL Rectangle (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  2036. {
  2037. struct IntuiMessage *Message;
  2038.  
  2039. UWORD MyCode;
  2040.  
  2041. LONG helpx,helpy;
  2042.  
  2043. ULONG MyClass;
  2044.  
  2045.   if (Win->UserPort->mp_SigBit)
  2046.   {
  2047.      if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
  2048.      {
  2049.         MyClass = Message->Class;
  2050.  
  2051.         MyCode  = Message->Code;
  2052.  
  2053.         GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2054.  
  2055.         switch (MyClass)
  2056.         {
  2057.           case IDCMP_MENUPICK    : if (MyCode != MENUNULL)
  2058.                                    {
  2059.                                       if (ProcessMenu (Win,MyCode) & STOP_MSG) return TRUE;
  2060.                                    }
  2061.  
  2062.                                    break;
  2063.  
  2064.           case IDCMP_RAWKEY      : if (MyCode == TAB)
  2065.                                    {
  2066.                                       DisplayBeep (Win->WScreen);
  2067.  
  2068.                                       Delay (30L);
  2069.  
  2070.                                       return FALSE;
  2071.                                    }
  2072.  
  2073.                                    if (MyCode == RAW_ESC)
  2074.                                    {
  2075.                                       DisplayBeep (Win->WScreen);
  2076.  
  2077.                                       return TRUE;
  2078.                                    }
  2079.  
  2080.                                    break;
  2081.  
  2082.           case IDCMP_CLOSEWINDOW : return TRUE;
  2083.         }
  2084.      }
  2085.   }
  2086.  
  2087.   helpx = a2 - a1;
  2088.  
  2089.   helpy = b2 - b1;
  2090.  
  2091.   if ((helpx < MINLIMIT) || (helpy < MINLIMIT)) return FALSE;
  2092.  
  2093.   if (CheckBox (Win->RPort,a1,b1,a2,b2))
  2094.   {
  2095.      SetAPen (Win->RPort,ReadPixel (Win->RPort,a1,b1));
  2096.  
  2097.      RectFill (Win->RPort,a1+1L,b1+1L,a2-1L,b2-1L);
  2098.  
  2099.      return FALSE;
  2100.   }
  2101.  
  2102.   if ((helpx < (MINLIMIT << 1L)) || (helpy < (MINLIMIT << 1L)))
  2103.   {
  2104.      for (helpy = (b1 + 1L); helpy <= (b2 - 1L); helpy++)
  2105.      {
  2106.          (*H_LINE) (Win->RPort,a1+1L,a2-1L,helpy);
  2107.      }
  2108.  
  2109.      return FALSE;
  2110.   }
  2111.  
  2112.   if (helpx >= helpy)
  2113.   {
  2114.      helpx = (a1 + a2) >> 1L;
  2115.  
  2116.      (*V_LINE) (Win->RPort,b1+1L,b2-1L,helpx);
  2117.  
  2118.      if (Rectangle (Win,a1,b1,helpx,b2)) return TRUE;
  2119.  
  2120.      if (Rectangle (Win,helpx,b1,a2,b2)) return TRUE;
  2121.   }
  2122.  
  2123.   else
  2124.   {
  2125.      helpy = (b1 + b2) >> 1L;
  2126.  
  2127.      (*H_LINE) (Win->RPort,a1+1L,a2-1L,helpy);
  2128.  
  2129.      if (Rectangle (Win,a1,b1,a2,helpy)) return TRUE;
  2130.  
  2131.      if (Rectangle (Win,a1,helpy,a2,b2)) return TRUE;
  2132.   }
  2133.  
  2134.   return FALSE;
  2135. }
  2136.  
  2137. ULONG DrawFractal (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  2138. {
  2139. ULONG StartSec = NULL , EndSec = NULL , Dummy = NULL;
  2140.  
  2141.  CurrentTime (&StartSec,&Dummy);
  2142.  
  2143.  INCREMREAL = (fabs (RMAX-RMIN)) / ((long double) (a2 - a1 + 1L));
  2144.  
  2145.  INCREMIMAG = (fabs (IMAX-IMIN)) / ((long double) (b2 - b1 + 1L));
  2146.  
  2147.  ITERATIONS = MAX_ITERATIONS + 1;
  2148.  
  2149.  if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
  2150.  
  2151.  (*H_LINE) (Win->RPort,a1,a2,b1);
  2152.  
  2153.  (*V_LINE) (Win->RPort,b1+1L,b2-1L,a2);
  2154.  
  2155.  (*H_LINE) (Win->RPort,a1,a2,b2);
  2156.  
  2157.  (*V_LINE) (Win->RPort,b1+1L,b2-1L,a1);
  2158.  
  2159.  Rectangle (Win,a1,b1,a2,b2);
  2160.  
  2161.  if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
  2162.  
  2163.  CurrentTime (&EndSec,&Dummy);
  2164.  
  2165.  DisplayBeep (Win->WScreen);
  2166.  
  2167.  return (EndSec-StartSec);
  2168. }
  2169.  
  2170. BOOL Preview (struct Window *Win,WORD Width,WORD Height)
  2171. {
  2172. struct Window *PreviewWin;
  2173.  
  2174. struct IntuiMessage *Message;
  2175.  
  2176. BOOL Error = FALSE;
  2177.  
  2178. UWORD MyCode;
  2179.  
  2180. ULONG MyClass;
  2181.  
  2182.  MYBITMAP = CopyBitMap (Win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  2183.  
  2184.  PreviewWin = OpenWindowTags (0,WA_Left,Win->LeftEdge + 25,
  2185.                                 WA_Top,Win->TopEdge + 35,
  2186.                                 WA_Width,(WORD) (Width  >> 1L),
  2187.                                 WA_Height,(WORD) (Height >> 1L),
  2188.                                 WA_Title,"Preview window",
  2189.                                 WA_ScreenTitle,"¼ Window preview...",
  2190.                                 WA_CustomScreen,Win->WScreen,
  2191.                                 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
  2192.                                 WA_Flags,WFLG_ACTIVATE|WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_RMBTRAP|WFLG_GIMMEZEROZERO,
  2193.                                 WA_BusyPointer,TRUE,
  2194.                                 TAG_END);
  2195.  if (PreviewWin)
  2196.  {
  2197.     PasteBitMap (MYBITMAP,PreviewWin,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  2198.  
  2199.     PutPointer (PreviewWin,0,0,0,0,0,BUSY_POINTER);
  2200.  
  2201.     ELAPSEDTIME = DrawFractal (PreviewWin,0L,0L,(LONG) (PreviewWin->GZZWidth) - 1L,(LONG) (PreviewWin->GZZHeight) - 1L);
  2202.  
  2203.     PutPointer (PreviewWin,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  2204.  
  2205.     ShowTime (Win,"Preview elapsed time:",ELAPSEDTIME);
  2206.  
  2207.     while (1L)
  2208.     {
  2209.          WaitPort (PreviewWin->UserPort);
  2210.  
  2211.          if (Message = (struct IntuiMessage *) GT_GetIMsg (PreviewWin->UserPort))
  2212.          {
  2213.             MyClass = Message->Class;
  2214.  
  2215.             MyCode  = Message->Code;
  2216.  
  2217.             GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2218.  
  2219.             if (MyClass == IDCMP_CLOSEWINDOW) break;
  2220.  
  2221.             if ((MyClass == IDCMP_RAWKEY) && (MyCode == RAW_ESC)) break;
  2222.          }
  2223.     }
  2224.  
  2225.     PutPointer (PreviewWin,0,0,0,0,0,CLEAR_POINTER);
  2226.  
  2227.     CloseWindow (PreviewWin);
  2228.  }
  2229.  
  2230.  else
  2231.  {
  2232.     if (BMASK & MASK)
  2233.     {
  2234.        FreeBitMap (MYBITMAP);
  2235.  
  2236.        MASK ^= BMASK;
  2237.     }
  2238.  
  2239.     Fail (PreviewWindowError,15L);
  2240.  
  2241.     Error = TRUE;
  2242.  }
  2243.  
  2244.  return Error;
  2245. }
  2246.  
  2247. BOOL DrawFrame (struct Window *Win,WORD Zx,WORD Zy,WORD Zw,WORD Zh)
  2248. {
  2249. WORD LeftEdge,TopEdge,RightEdge,BottomEdge;
  2250.  
  2251.   if ((Zx > 2) && (Zy > 2) && (Zx < Win->Width - 2) && (Zy < Win->Height - 2) && ((Zw >= INITIALZOOM) || (Zh >= INITIALZOOM)))
  2252.   {
  2253.      LeftEdge   = Zx - Zw;
  2254.  
  2255.      TopEdge    = Zy - Zh;
  2256.  
  2257.      RightEdge  = Zx + Zw;
  2258.  
  2259.      BottomEdge = Zy + Zh;
  2260.  
  2261.      if ((LeftEdge >= 0) && (TopEdge >= 0) && (RightEdge <= Win->Width) && (BottomEdge <= Win->Height))
  2262.      {
  2263.         ZOOMLINE [8] = ZOOMLINE [0] = ZOOMLINE [6] = LeftEdge;
  2264.  
  2265.         ZOOMLINE [1] = ZOOMLINE [3] = ZOOMLINE [9] = TopEdge;
  2266.  
  2267.         ZOOMLINE [2] = ZOOMLINE [4] = RightEdge;
  2268.  
  2269.         ZOOMLINE [5] = ZOOMLINE [7] = BottomEdge;
  2270.      }
  2271.  
  2272.      DrawBorder (Win->RPort,&MYBORDER,0,0);
  2273.  
  2274.      MASK |= ZMASK;
  2275.   }
  2276.  
  2277.   else MASK ^= ZMASK;
  2278.  
  2279.   return (BOOL) (ZMASK & MASK);
  2280. }
  2281.  
  2282. BOOL FileRequest (struct Window *Win,TEXT *String,TEXT *DrawerTxt,BOOL DrawerType,BOOL Save)
  2283. {
  2284. struct FileRequester *MyFileReq;
  2285.  
  2286. static struct EasyStruct MyReq = { sizeof (struct EasyStruct),0,"Overwrite file requester","File already exists...\n\nDo you want overwrite it ?","Yes|No" };
  2287.  
  2288. BPTR MyLock;
  2289.  
  2290. BOOL Success = FALSE;
  2291.  
  2292.   if (MyFileReq = AllocAslRequest (ASL_FileRequest,0))
  2293.   {
  2294.      MYDIR = (DrawerType ? PALETTESDIR : PICTURESDIR);
  2295.  
  2296.      if (! strlen (MYDIR)) strcpy (MYDIR,DrawerTxt);
  2297.  
  2298.      if (AslRequestTags (MyFileReq,ASLFR_Window,Win,
  2299.                                    ASLFR_InitialLeftEdge,Win->LeftEdge + 25,
  2300.                                    ASLFR_InitialTopEdge,Win->TopEdge + 35,
  2301.                                    ASLFR_InitialWidth,300,
  2302.                                    ASLFR_InitialHeight,((Win->Height) * 7) >> 3,
  2303.                                    ASLFR_SleepWindow,TRUE,
  2304.                                    ASLFR_TextAttr,&MYFONTSTRUCT,
  2305.                                    ASLFR_TitleText,String,
  2306.                                    ASLFR_InitialDrawer,MYDIR,
  2307.                                    ASLFR_InitialFile,MYFILE,
  2308.                                    ASLFR_DoSaveMode,Save,
  2309.                                    ASLFR_RejectIcons,TRUE,
  2310.                                    TAG_END))
  2311.      {
  2312.         strcpy (MYFILE,MyFileReq->rf_File);
  2313.  
  2314.         strcpy (MYDIR,MyFileReq->rf_Dir);
  2315.  
  2316.         strcpy (MYPATH,MYDIR);
  2317.  
  2318.         Success = AddPart (MYPATH,MYFILE,sizeof (MYPATH));
  2319.      }
  2320.  
  2321.      FreeAslRequest (MyFileReq);
  2322.  
  2323.      if (Save)
  2324.      {
  2325.         if (MyLock = Lock (MYPATH,ACCESS_READ))
  2326.         {
  2327.            UnLock (MyLock);
  2328.  
  2329.            if (! EasyRequest (Win,&MyReq,0)) Success = FALSE;
  2330.         }
  2331.      }
  2332.   }
  2333.  
  2334.   return Success;
  2335. }
  2336.  
  2337. BOOL FontRequest (struct Window *Win)
  2338. {
  2339. struct FontRequester *MyFontReq;
  2340.  
  2341. BOOL Success = FALSE;
  2342.  
  2343.   if (MyFontReq = AllocAslRequest (ASL_FontRequest,0))
  2344.   {
  2345.      if (AslRequestTags (MyFontReq,ASLFO_Window,Win,
  2346.                                    ASLFO_InitialLeftEdge,Win->LeftEdge + 25,
  2347.                                    ASLFO_InitialTopEdge,Win->TopEdge + 35,
  2348.                                    ASLFO_InitialWidth,300,
  2349.                                    ASLFO_InitialHeight,((Win->Height) * 7) >> 3,
  2350.                                    ASLFO_SleepWindow,TRUE,
  2351.                                    ASLFO_TextAttr,&MYFONTSTRUCT,
  2352.                                    ASLFO_TitleText,"Font requester",
  2353.                                    ASLFO_InitialName,MYFONTSTRUCT.ta_Name,
  2354.                                    ASLFO_InitialSize,MYFONTSTRUCT.ta_YSize,
  2355.                                    ASLFO_InitialStyle,MYFONTSTRUCT.ta_Style,
  2356.                                    ASLFO_InitialFlags,MYFONTSTRUCT.ta_Flags,
  2357.                                    ASLFO_DoFrontPen,TRUE,
  2358.                                    ASLFO_DoBackPen,TRUE,
  2359.                                    ASLFO_DoStyle,TRUE,
  2360.                                    ASLFO_DoDrawMode,TRUE,
  2361.                                    ASLFO_MinHeight,8,
  2362.                                    ASLFO_MaxHeight,24,
  2363.                                    TAG_END))
  2364.      {
  2365.        strcpy (MYFONTSTRUCT.ta_Name,MyFontReq->fo_Attr.ta_Name);
  2366.  
  2367.        MYFONTSTRUCT.ta_YSize = MyFontReq->fo_Attr.ta_YSize;
  2368.  
  2369.        MYFONTSTRUCT.ta_Style = MyFontReq->fo_Attr.ta_Style;
  2370.  
  2371.        MYFONTSTRUCT.ta_Flags = MyFontReq->fo_Attr.ta_Flags;
  2372.  
  2373.        Success = TRUE;
  2374.      }
  2375.  
  2376.      FreeAslRequest (MyFontReq);
  2377.   }
  2378.  
  2379.   return Success;
  2380. }
  2381.  
  2382. static ULONG __saveds __asm SMFilterFunc (register __a0 struct Hook *Hook,register __a2 struct ScreenModeRequester *SMReq,register __a1 ULONG DisplayID)
  2383. {
  2384. DisplayInfoHandle DisplayHandle;
  2385.  
  2386. struct DisplayInfo DisplayInfo;
  2387.  
  2388. struct DimensionInfo DimensionInfo;
  2389.  
  2390. ULONG Accept = NULL;
  2391.  
  2392.   DisplayHandle = FindDisplayInfo (DisplayID);
  2393.  
  2394.   if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DisplayInfo,sizeof (struct DisplayInfo),DTAG_DISP,DisplayID))
  2395.   {
  2396.      if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DimensionInfo,sizeof (struct DimensionInfo),DTAG_DIMS,DisplayID))
  2397.      {
  2398.         Accept = (ULONG) (DimensionInfo.MaxDepth <= MAX_DEPTH) && ((DisplayInfo.PropertyFlags & DIPF_IS_WB) || (DisplayInfo.PropertyFlags & DIPF_IS_EXTRAHALFBRITE));
  2399.      }
  2400.   }
  2401.  
  2402.   return Accept;
  2403. }
  2404.  
  2405. BOOL SMRequest (struct ILBMInfo *Ilbm)
  2406. {
  2407. struct ScreenModeRequester *SMReq;
  2408.  
  2409. struct Window *Win = Ilbm->win;
  2410.  
  2411. BOOL NewScreen = FALSE;
  2412.  
  2413.  if (SMReq = AllocAslRequest (ASL_ScreenModeRequest,NULL))
  2414.  {
  2415.     if (AslRequestTags (SMReq,ASLSM_Window,Win,
  2416.                               ASLSM_SleepWindow,TRUE,
  2417.                               ASLSM_TitleText,"ScreenMode requester",
  2418.                               ASLSM_InitialLeftEdge,Win->LeftEdge + 25,
  2419.                               ASLSM_InitialTopEdge,Win->TopEdge + 35,
  2420.                               ASLSM_InitialWidth,310,
  2421.                               ASLSM_InitialHeight,((Win->Height) * 7) >> 3,
  2422.                               ASLSM_InitialDisplayID,GetVPModeID (Ilbm->vp),
  2423.                               ASLSM_InitialDisplayWidth,Win->Width,
  2424.                               ASLSM_InitialDisplayHeight,Win->Height,
  2425.                               ASLSM_InitialDisplayDepth,Ilbm->wrp->BitMap->Depth,
  2426.                               ASLSM_InitialOverscanType,Ilbm->ucliptype,
  2427.                               ASLSM_InitialInfoOpened,TRUE,
  2428.                               ASLSM_InitialInfoLeftEdge,Win->LeftEdge + 310 + 15,
  2429.                               ASLSM_InitialInfoTopEdge,Win->TopEdge,
  2430.                               ASLSM_DoWidth,TRUE,
  2431.                               ASLSM_DoHeight,TRUE,
  2432.                               ASLSM_DoDepth,TRUE,
  2433.                               ASLSM_DoOverscanType,TRUE,
  2434.                               ASLSM_MinDepth,MIN_DEPTH,
  2435.                               ASLSM_MaxDepth,MAX_DEPTH,
  2436.                               ASLSM_PropertyFlags,DIPF_IS_WB|DIPF_IS_EXTRAHALFBRITE,
  2437.                               ASLSM_PropertyMask,DIPF_IS_DUALPF|DIPF_IS_PF2PRI|DIPF_IS_HAM,
  2438.                               ASLSM_FilterFunc,&SMFILTERHOOK,
  2439.                               ASLSM_MinWidth,MIN_WIDTH,
  2440.                               ASLSM_MinHeight,MIN_HEIGHT,
  2441.                               TAG_END))
  2442.     {
  2443.        Ilbm->camg = SMReq->sm_DisplayID;
  2444.  
  2445.        Ilbm->Bmhd.w = SMReq->sm_DisplayWidth;
  2446.  
  2447.        Ilbm->Bmhd.h = SMReq->sm_DisplayHeight;
  2448.  
  2449.        Ilbm->Bmhd.nPlanes = SMReq->sm_DisplayDepth;
  2450.  
  2451.        Ilbm->ucliptype = SMReq->sm_OverscanType;
  2452.  
  2453.        NewScreen = TRUE;
  2454.     }
  2455.  
  2456.     FreeAslRequest (SMReq);
  2457.  }
  2458.  
  2459.  return NewScreen;
  2460. }
  2461.  
  2462. VOID SetMenuStart (struct Window *Win)
  2463. {
  2464.   OnMenu  (Win,FULLMENUNUM (0,0,NOSUB));
  2465.  
  2466.   OnMenu  (Win,FULLMENUNUM (0,2,NOSUB));
  2467.  
  2468.   OnMenu  (Win,FULLMENUNUM (0,3,NOSUB));
  2469.  
  2470.   OnMenu  (Win,FULLMENUNUM (0,4,NOSUB));
  2471.  
  2472.   OnMenu  (Win,FULLMENUNUM (0,5,NOSUB));
  2473.  
  2474.   OnMenu  (Win,FULLMENUNUM (0,7,NOSUB));
  2475.  
  2476.   OnMenu  (Win,FULLMENUNUM (0,9,NOSUB));
  2477.  
  2478.   OnMenu  (Win,FULLMENUNUM (1,0,NOSUB));
  2479.  
  2480.   OnMenu  (Win,FULLMENUNUM (1,1,NOSUB));
  2481.  
  2482.   OnMenu  (Win,FULLMENUNUM (1,2,NOSUB));
  2483.  
  2484.   OnMenu  (Win,FULLMENUNUM (1,4,NOSUB));
  2485.  
  2486.   OnMenu  (Win,FULLMENUNUM (2,2,NOSUB));
  2487.  
  2488.   OnMenu  (Win,FULLMENUNUM (2,4,NOSUB));
  2489.  
  2490.   OffMenu (Win,FULLMENUNUM (2,7,NOSUB));
  2491.  
  2492.   OnMenu  (Win,FULLMENUNUM (3,0,NOSUB));
  2493.  
  2494.   OnMenu  (Win,FULLMENUNUM (3,2,NOSUB));
  2495.  
  2496.   OnMenu  (Win,FULLMENUNUM (3,4,NOSUB));
  2497.  
  2498.   OnMenu  (Win,FULLMENUNUM (3,6,NOSUB));
  2499. }
  2500.  
  2501. VOID SetMenuStop (struct Window *Win)
  2502. {
  2503.   OffMenu  (Win,FULLMENUNUM (0,0,NOSUB));
  2504.  
  2505.   OffMenu  (Win,FULLMENUNUM (0,2,NOSUB));
  2506.  
  2507.   OffMenu  (Win,FULLMENUNUM (0,3,NOSUB));
  2508.  
  2509.   OffMenu  (Win,FULLMENUNUM (0,4,NOSUB));
  2510.  
  2511.   OffMenu  (Win,FULLMENUNUM (0,5,NOSUB));
  2512.  
  2513.   OffMenu  (Win,FULLMENUNUM (0,7,NOSUB));
  2514.  
  2515.   OffMenu  (Win,FULLMENUNUM (0,9,NOSUB));
  2516.  
  2517.   OffMenu  (Win,FULLMENUNUM (1,0,NOSUB));
  2518.  
  2519.   OffMenu  (Win,FULLMENUNUM (1,1,NOSUB));
  2520.  
  2521.   OffMenu  (Win,FULLMENUNUM (1,2,NOSUB));
  2522.  
  2523.   OffMenu  (Win,FULLMENUNUM (1,4,NOSUB));
  2524.  
  2525.   OffMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2526.  
  2527.   OffMenu  (Win,FULLMENUNUM (2,2,NOSUB));
  2528.  
  2529.   OffMenu  (Win,FULLMENUNUM (2,4,NOSUB));
  2530.  
  2531.   OffMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2532.  
  2533.   OnMenu   (Win,FULLMENUNUM (2,7,NOSUB));
  2534.  
  2535.   OffMenu  (Win,FULLMENUNUM (3,0,NOSUB));
  2536.  
  2537.   OffMenu  (Win,FULLMENUNUM (3,2,NOSUB));
  2538.  
  2539.   OffMenu  (Win,FULLMENUNUM (3,4,NOSUB));
  2540.  
  2541.   OffMenu  (Win,FULLMENUNUM (3,6,NOSUB));
  2542. }
  2543.  
  2544. ULONG ProcessMenu (struct Window *Win,UWORD Code)
  2545. {
  2546. struct MenuItem *Item;
  2547.  
  2548. ULONG Choice = NULL;
  2549.  
  2550.  while (Code != MENUNULL)
  2551.  {
  2552.   Item = ItemAddress (MAINMENU,(ULONG) Code);
  2553.  
  2554.   switch (MENUNUM (Code))
  2555.   {
  2556.         case 0:    switch (ITEMNUM (Code))
  2557.                    {
  2558.                         case 0: Choice |= ABOUT_MSG;
  2559.  
  2560.                                 break;
  2561.  
  2562.                         case 2: Choice |= LOADPICTURE_MSG;
  2563.  
  2564.                                 break;
  2565.  
  2566.                         case 3: Choice |= SAVEPICTURE_MSG;
  2567.  
  2568.                                 break;
  2569.  
  2570.                         case 4: Choice |= LOADPALETTE_MSG;
  2571.  
  2572.                                 break;
  2573.  
  2574.                         case 5: Choice |= SAVEPALETTE_MSG;
  2575.  
  2576.                                 break;
  2577.  
  2578.                         case 7: Choice |= DUMP_MSG;
  2579.  
  2580.                                 break;
  2581.  
  2582.                         case 9: Choice |= EXIT_MSG;
  2583.  
  2584.                                 break;
  2585.                    }
  2586.  
  2587.                    break;
  2588.  
  2589.         case 1:    switch (ITEMNUM (Code))
  2590.                    {
  2591.                         case 0: switch (SUBNUM (Code))
  2592.                                 {
  2593.                                    case 0: Choice |= TITLE_MSG;
  2594.  
  2595.                                            break;
  2596.  
  2597.                                    case 2: Choice |= TIME_MSG;
  2598.  
  2599.                                            break;
  2600.                                 }
  2601.  
  2602.                                 break;
  2603.  
  2604.                         case 1: Choice |= COORDS_MSG;
  2605.  
  2606.                                 break;
  2607.  
  2608.                         case 2: switch (SUBNUM (Code))
  2609.                                 {
  2610.                                    case 0: MAX_ITERATIONS = 63;
  2611.  
  2612.                                            break;
  2613.  
  2614.                                    case 1: MAX_ITERATIONS = 127;
  2615.  
  2616.                                            break;
  2617.  
  2618.                                    case 2: MAX_ITERATIONS = 191;
  2619.  
  2620.                                            break;
  2621.  
  2622.                                    case 3: MAX_ITERATIONS = 255;
  2623.  
  2624.                                            break;
  2625.  
  2626.                                    case 4: MAX_ITERATIONS = 319;
  2627.  
  2628.                                            break;
  2629.  
  2630.                                    case 5: MAX_ITERATIONS = 383;
  2631.  
  2632.                                            break;
  2633.  
  2634.                                    case 6: MAX_ITERATIONS = 447;
  2635.  
  2636.                                            break;
  2637.  
  2638.                                    case 7: MAX_ITERATIONS = 511;
  2639.  
  2640.                                            break;
  2641.  
  2642.                                    case 8: MAX_ITERATIONS = 1023;
  2643.  
  2644.                                            break;
  2645.  
  2646.                                   case 10: Choice |= ITER_MSG;
  2647.  
  2648.                                            break;
  2649.                                 }
  2650.  
  2651.                                 break;
  2652.  
  2653.                         case 3: switch (SUBNUM (Code))
  2654.                                 {
  2655.                                    case  0: PRIORITY = -5;
  2656.  
  2657.                                             break;
  2658.  
  2659.                                    case  1: PRIORITY = -4;
  2660.  
  2661.                                             break;
  2662.  
  2663.                                    case  2: PRIORITY = -3;
  2664.  
  2665.                                             break;
  2666.  
  2667.                                    case  3: PRIORITY = -2;
  2668.  
  2669.                                             break;
  2670.  
  2671.                                    case  4: PRIORITY = -1;
  2672.  
  2673.                                             break;
  2674.  
  2675.                                    case  6: PRIORITY =  0;
  2676.  
  2677.                                             break;
  2678.  
  2679.                                    case  8: PRIORITY =  1;
  2680.  
  2681.                                             break;
  2682.  
  2683.                                    case  9: PRIORITY =  2;
  2684.  
  2685.                                             break;
  2686.  
  2687.                                    case 10: PRIORITY =  3;
  2688.  
  2689.                                             break;
  2690.  
  2691.                                    case 11: PRIORITY =  4;
  2692.  
  2693.                                             break;
  2694.  
  2695.                                    case 12: PRIORITY =  5;
  2696.  
  2697.                                             break;
  2698.  
  2699.                                 }
  2700.  
  2701.                                 Forbid ();
  2702.  
  2703.                                 THISTASK = FindTask (NULL);
  2704.  
  2705.                                 Permit ();
  2706.  
  2707.                                 SetTaskPri (THISTASK,PRIORITY);
  2708.  
  2709.                                 break;
  2710.  
  2711.                         case 4: switch (SUBNUM (Code))
  2712.                                 {
  2713.                                    case 0: if (CheckEHB (GetVPModeID (ViewPortAddress (Win))))
  2714.                                            {
  2715.                                               H_LINE = HLine_R_EHB;
  2716.  
  2717.                                               V_LINE = VLine_R_EHB;
  2718.                                            }
  2719.  
  2720.                                            else
  2721.                                            {
  2722.                                               H_LINE = HLine_R;
  2723.  
  2724.                                               V_LINE = VLine_R;
  2725.                                            }
  2726.  
  2727.                                            SPREAD = FALSE;
  2728.  
  2729.                                            break;
  2730.  
  2731.                                    case 1: if (CheckEHB (GetVPModeID (ViewPortAddress (Win))))
  2732.                                            {
  2733.                                               H_LINE = HLine_S_EHB;
  2734.  
  2735.                                               V_LINE = VLine_S_EHB;
  2736.                                            }
  2737.  
  2738.                                            else
  2739.                                            {
  2740.                                               H_LINE = HLine_S;
  2741.  
  2742.                                               V_LINE = VLine_S;
  2743.                                            }
  2744.  
  2745.                                            SPREAD = TRUE;
  2746.  
  2747.                                            break;
  2748.                                 }
  2749.  
  2750.                                 break;
  2751.  
  2752.                         case 5: switch (SUBNUM (Code))
  2753.                                 {
  2754.                                    case 0: FUNCTION = Integer;
  2755.  
  2756.                                            break;
  2757.  
  2758.                                    case 1: FUNCTION = Real;
  2759.  
  2760.                                            break;
  2761.  
  2762.                                    case 2: FUNCTION = Ppc;
  2763.  
  2764.                                            break;
  2765.                                 }
  2766.  
  2767.                                 break;
  2768.                    }
  2769.  
  2770.                    break;
  2771.  
  2772.         case 2: switch (ITEMNUM (Code))
  2773.                 {
  2774.                    case 0: Choice |= PREVIEW_MSG;
  2775.  
  2776.                            break;
  2777.  
  2778.                    case 2: Choice |= REDRAW_MSG;
  2779.  
  2780.                            break;
  2781.  
  2782.                    case 4: Choice |= UNDO_MSG;
  2783.  
  2784.                            break;
  2785.  
  2786.                    case 6: Choice |= DRAW_MSG;
  2787.  
  2788.                            break;
  2789.  
  2790.                    case 7: Choice |= STOP_MSG;
  2791.  
  2792.                            break;
  2793.                 }
  2794.  
  2795.                 break;
  2796.  
  2797.         case 3: switch (ITEMNUM (Code))
  2798.                 {
  2799.                    case 0: switch (SUBNUM (Code))
  2800.                            {
  2801.                               case 0: Choice |= CYCLERIGHT_MSG;
  2802.  
  2803.                                       break;
  2804.  
  2805.                               case 1: Choice |= CYCLELEFT_MSG;
  2806.  
  2807.                                       break;
  2808.  
  2809.                               case 3: Choice |= DELAY_MSG;
  2810.  
  2811.                                       break;
  2812.  
  2813.                            }
  2814.  
  2815.                            break;
  2816.  
  2817.                    case 2: Choice |= PALETTE_MSG;
  2818.  
  2819.                            break;
  2820.  
  2821.                    case 4: Choice |= NEWDISPLAY_MSG;
  2822.  
  2823.                            break;
  2824.  
  2825.                    case 6: Choice |= FONTREQ_MSG;
  2826.  
  2827.                            break;
  2828.                 }
  2829.   }
  2830.  
  2831.  Code = Item->NextSelect;
  2832.  }
  2833.  
  2834.  return Choice;
  2835. }
  2836.  
  2837. VOID ProcessMouse (struct Window *Win,WORD CurMouseX,WORD CurMouseY)
  2838. {
  2839. static WORD MX1 = 0 , MY1 = 0 , MX2 = 0 , MY2 = 0, W = 0, H = 0;
  2840.  
  2841. struct IntuiMessage *Message;
  2842.  
  2843. UWORD MyCode;
  2844.  
  2845. LONG DefaultQueue;
  2846.  
  2847. ULONG MyClass;
  2848.  
  2849.    ModifyIDCMP (Win,IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE);
  2850.  
  2851.    DefaultQueue = SetMouseQueue (Win,10);
  2852.  
  2853.    if (ZMASK & MASK) DrawFrame (Win,MX1,MY1,W,H);
  2854.  
  2855.    MX1 = CurMouseX;
  2856.  
  2857.    MY1 = CurMouseY;
  2858.  
  2859.    W = INITIALZOOM;
  2860.  
  2861.    H = ScalerDiv ((LONG) W,(ULONG) Win->Height,(ULONG) Win->Width);
  2862.  
  2863.    DrawFrame (Win,MX1,MY1,W,H);
  2864.  
  2865.    while (1L)
  2866.    {
  2867.      WaitPort (Win->UserPort);
  2868.  
  2869.      if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
  2870.      {
  2871.         MyClass = Message->Class;
  2872.  
  2873.         MyCode = Message->Code;
  2874.  
  2875.         MX2 = Message->MouseX;
  2876.  
  2877.         MY2 = Message->MouseY;
  2878.  
  2879.         GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2880.  
  2881.         if (MyClass == IDCMP_MOUSEMOVE)
  2882.         {
  2883.            DrawFrame (Win,MX1,MY1,W,H);
  2884.  
  2885.            W = abs (MX1 - MX2);
  2886.  
  2887.            H = abs (MY1 - MY2);
  2888.  
  2889.            if (W > H) (W = ScalerDiv ((LONG) H,(ULONG) Win->Width,(ULONG) Win->Height));
  2890.  
  2891.            else (H = ScalerDiv ((LONG) W,(ULONG) Win->Height,(ULONG) Win->Width));
  2892.  
  2893.            DrawFrame (Win,MX1,MY1,W,H);
  2894.         }
  2895.  
  2896.         else if ((MyClass == IDCMP_MOUSEBUTTONS) && (MyCode != SELECTDOWN)) break;
  2897.      }
  2898.    }
  2899.  
  2900.    SetMouseQueue (Win,(ULONG) DefaultQueue);
  2901.  
  2902.    ModifyIDCMP (Win,IDCMP_STANDARD);
  2903.  
  2904.    if (ZMASK & MASK)
  2905.    {
  2906.       OnMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2907.  
  2908.       OnMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2909.    }
  2910.  
  2911.    else
  2912.    {
  2913.       OffMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2914.  
  2915.       OffMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2916.    }
  2917. }
  2918.  
  2919. ULONG HandleEvents (struct ILBMInfo *Ilbm)
  2920. {
  2921. struct IntuiMessage *Message;
  2922.  
  2923. WORD MouseX,MouseY;
  2924.  
  2925. UWORD MyCode;
  2926.  
  2927. LONG Error;
  2928.  
  2929. ULONG MyClass,MyMenu = NULL,Index;
  2930.  
  2931. DOUBLE RealCoord,ImagCoord,ScrRatio,FracRatio;
  2932.  
  2933.  PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  2934.  
  2935.  do { WaitPort (Ilbm->win->UserPort);
  2936.  
  2937.       if (Message = (struct IntuiMessage *) GT_GetIMsg (Ilbm->win->UserPort))
  2938.       {
  2939.          MyClass = Message->Class;
  2940.  
  2941.          MyCode  = Message->Code;
  2942.  
  2943.          MouseX  = Message->MouseX;
  2944.  
  2945.          MouseY  = Message->MouseY;
  2946.  
  2947.          GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2948.  
  2949.          switch (MyClass)
  2950.          {
  2951.                 case    IDCMP_MOUSEMOVE: if (TMASK & MASK)
  2952.                                          {
  2953.                                             RealCoord = RMIN + ((DOUBLE) MouseX * fabs (RMAX-RMIN) / (DOUBLE) (Ilbm->win->Width - 1));
  2954.  
  2955.                                             ImagCoord = IMAX - ((DOUBLE) MouseY * fabs (IMAX-IMIN) / (DOUBLE) (Ilbm->win->Height - 1));
  2956.  
  2957.                                             ScrRatio  = (DOUBLE) Ilbm->win->Width / (DOUBLE) Ilbm->win->Height;
  2958.  
  2959.                                             FracRatio = fabs (RMAX-RMIN) / fabs (IMAX-IMIN);
  2960.  
  2961.                                             sprintf (BAR_STRING,"Real %+2.16lf Imag %+2.16lfi W:H %.5lf R:I %.5lf",RealCoord,ImagCoord,ScrRatio,FracRatio);
  2962.  
  2963.                                             WaitTOF ();
  2964.  
  2965.                                             SetWindowTitles (Ilbm->win,(TEXT *) ~0,BAR_STRING);
  2966.                                          }
  2967.  
  2968.                                          break;
  2969.  
  2970.                 case IDCMP_MOUSEBUTTONS: if (MyCode == SELECTDOWN) ProcessMouse (Ilbm->win,MouseX,MouseY);
  2971.  
  2972.                                          break;
  2973.  
  2974.                 case     IDCMP_MENUPICK: MyMenu = ProcessMenu (Ilbm->win,MyCode);
  2975.  
  2976.                                          if (MyMenu & EXIT_MSG) break;
  2977.  
  2978.                                          if (MyMenu & TITLE_MSG)
  2979.                                          {
  2980.                                             if (TMASK & MASK) MASK ^= TMASK;
  2981.  
  2982.                                             else MASK |= TMASK;
  2983.  
  2984.                                             Ilbm->TBState = TMASK & MASK;
  2985.  
  2986.                                             ShowTitle (Ilbm->scr,(LONG) Ilbm->TBState);
  2987.  
  2988.                                             break;
  2989.                                          }
  2990.  
  2991.                                          if (MyMenu & TIME_MSG)
  2992.                                          {
  2993.                                             if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,TRUE);
  2994.  
  2995.                                             ShowTime (Ilbm->win,"Last calculating time:",ELAPSEDTIME);
  2996.  
  2997.                                             Delay (MYSECS);
  2998.  
  2999.                                             if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,FALSE);
  3000.  
  3001.                                             break;
  3002.                                          }
  3003.  
  3004.                                          if (MyMenu & ITER_MSG)
  3005.                                          {
  3006.                                             ModifyIDCMP (Ilbm->win,NULL);
  3007.  
  3008.                                             ClearMenuStrip (Ilbm->win);
  3009.  
  3010.                                             while (1L)
  3011.                                             {
  3012.                                                MAX_ITERATIONS = (WORD) IntegerGad (Ilbm->win,"Iterations requester","Insert new iterations...","_Iterations",MAX_ITERATIONS + 1L) - 1L;
  3013.  
  3014.                                                if (MAX_ITERATIONS >= MIN_ITERATIONS) break;
  3015.  
  3016.                                                DisplayBeep (Ilbm->scr);
  3017.  
  3018.                                                MAX_ITERATIONS = MIN_ITERATIONS;
  3019.                                             }
  3020.  
  3021.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3022.  
  3023.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3024.  
  3025.                                             break;
  3026.                                          }
  3027.  
  3028.                                          if (MyMenu & ABOUT_MSG)
  3029.                                          {
  3030.                                             ModifyIDCMP (Ilbm->win,NULL);
  3031.  
  3032.                                             ClearMenuStrip (Ilbm->win);
  3033.  
  3034.                                             About (Ilbm->win);
  3035.  
  3036.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3037.  
  3038.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3039.  
  3040.                                             break;
  3041.                                          }
  3042.  
  3043.                                          if (MyMenu & PALETTE_MSG)
  3044.                                          {
  3045.                                             ModifyIDCMP (Ilbm->win,NULL);
  3046.  
  3047.                                             ClearMenuStrip (Ilbm->win);
  3048.  
  3049.                                             if (! ModifyPalette (Ilbm->win,Ilbm->win->LeftEdge + 25,Ilbm->win->TopEdge + 35,PALETTE)) Fail (PaletteRequesterError,15L);
  3050.  
  3051.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3052.  
  3053.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3054.  
  3055.                                             break;
  3056.                                          }
  3057.  
  3058.                                          if (MyMenu & CYCLERIGHT_MSG)
  3059.                                          {
  3060.                                             ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
  3061.  
  3062.                                             if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3063.  
  3064.                                             ClearMenuStrip (Ilbm->win);
  3065.  
  3066.                                             PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3067.  
  3068.                                             Cycle (Ilbm->win,DELAY,SHIFTRIGHT);
  3069.  
  3070.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3071.  
  3072.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3073.  
  3074.                                             if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3075.  
  3076.                                             LoadRGB32 (Ilbm->vp,PALETTE);
  3077.  
  3078.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3079.  
  3080.                                             break;
  3081.                                          }
  3082.  
  3083.                                          if (MyMenu & CYCLELEFT_MSG)
  3084.                                          {
  3085.                                             ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
  3086.  
  3087.                                             if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3088.  
  3089.                                             ClearMenuStrip (Ilbm->win);
  3090.  
  3091.                                             PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3092.  
  3093.                                             Cycle (Ilbm->win,DELAY,SHIFTLEFT);
  3094.  
  3095.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3096.  
  3097.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3098.  
  3099.                                             if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3100.  
  3101.                                             LoadRGB32 (Ilbm->vp,PALETTE);
  3102.  
  3103.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3104.  
  3105.                                             break;
  3106.                                          }
  3107.  
  3108.                                          if (MyMenu & DELAY_MSG)
  3109.                                          {
  3110.                                             while (1L)
  3111.                                             {
  3112.                                                DELAY = IntegerGad (Ilbm->win,"Delay requester","Insert delay time...","_Delay time",DELAY);
  3113.  
  3114.                                                if ((DELAY >= 0L) && (DELAY <= 100)) break;
  3115.  
  3116.                                                DisplayBeep (Ilbm->scr);
  3117.                                             }
  3118.  
  3119.                                             break;
  3120.                                          }
  3121.  
  3122.                                          if (MyMenu & STOP_MSG)
  3123.                                          {
  3124.                                             SetMenuStart (Ilbm->win);
  3125.  
  3126.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3127.  
  3128.                                             break;
  3129.                                          }
  3130.  
  3131.                                          if (MyMenu & LOADPICTURE_MSG)
  3132.                                          {
  3133.                                             if (FileRequest (Ilbm->win,"Load iff picture","PROGDIR:Pictures",PICTURES_DRAWER,FALSE))
  3134.                                             {
  3135.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3136.  
  3137.                                                if (Ilbm->ParseInfo.iff = AllocIFF ())
  3138.                                                {
  3139.                                                   if (! (Error = QueryMandPic (Ilbm,&MANDChunkTmp,MYPATH)))
  3140.                                                   {
  3141.                                                      MANDChunk = *MANDChunkTmp;
  3142.  
  3143.                                                      SaveCoords ();
  3144.  
  3145.                                                      RMIN = MANDChunk.RMin;
  3146.  
  3147.                                                      RMAX = MANDChunk.RMax;
  3148.  
  3149.                                                      IMIN = MANDChunk.IMin;
  3150.  
  3151.                                                      IMAX = MANDChunk.IMax;
  3152.  
  3153.                                                      MAX_ITERATIONS = MANDChunk.Iterations - 1L;
  3154.  
  3155.                                                      if (MANDChunk.Special & SPREAD_BIT) SPREAD = TRUE;
  3156.  
  3157.                                                      else SPREAD = FALSE;
  3158.  
  3159.                                                      if (MANDChunk.Special & INTEGER_BIT) FUNCTION = Integer;
  3160.  
  3161.                                                      if (MANDChunk.Special & REAL_BIT) FUNCTION = Real;
  3162.  
  3163.                                                      if (MANDChunk.Special & PPC_BIT) FUNCTION = Ppc;
  3164.  
  3165.                                                      Fade (MYILBM.win,PALETTE,25L,1L,TOBLACK);
  3166.  
  3167.                                                      CloseDisplay (Ilbm,VINFO);
  3168.  
  3169.                                                      Ilbm->IFFPFlags = IFFPF_BESTFIT;
  3170.  
  3171.                                                      CURRENT_MAX_COLORS = MakeDisplay (Ilbm);
  3172.  
  3173.                                                      Ilbm->IFFPFlags = NULL;
  3174.  
  3175.                                                      if (! CURRENT_MAX_COLORS)
  3176.                                                      {
  3177.                                                         Fail (MakeDisplayError,20L);
  3178.  
  3179.                                                         MyMenu = EXIT_MSG;
  3180.  
  3181.                                                         break;
  3182.                                                      }
  3183.  
  3184.                                                      if (ZMASK & MASK) MASK ^= ZMASK;
  3185.  
  3186.                                                      CURRENT_MAX_COLORS -= RESERVED_PENS;
  3187.  
  3188.                                                      if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3189.  
  3190.                                                      if (LoadMandPic (Ilbm,MYPATH)) Fail (LoadMandPicError,5L);
  3191.  
  3192.                                                      if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3193.  
  3194.                                                      if (Ilbm->EHB) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&(PALETTE [1L]));
  3195.  
  3196.                                                      else GetRGB32 (Ilbm->vp->ColorMap,0L,(ULONG) Ilbm->vp->ColorMap->Count,&(PALETTE [1L]));
  3197.  
  3198.                                                      ClearMenuStrip (Ilbm->win);
  3199.  
  3200.                                                      if (SPREAD)
  3201.                                                      {
  3202.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags ^= CHECKED;
  3203.  
  3204.                                                         if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags |= CHECKED;
  3205.  
  3206.                                                         if (CheckEHB (Ilbm->camg))
  3207.                                                         {
  3208.                                                            H_LINE = HLine_S_EHB;
  3209.  
  3210.                                                            V_LINE = VLine_S_EHB;
  3211.                                                         }
  3212.  
  3213.                                                         else
  3214.                                                         {
  3215.                                                            H_LINE = HLine_S;
  3216.  
  3217.                                                            V_LINE = VLine_S;
  3218.                                                         }
  3219.                                                      }
  3220.  
  3221.                                                      else
  3222.                                                      {
  3223.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags ^= CHECKED;
  3224.  
  3225.                                                         if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags |= CHECKED;
  3226.  
  3227.                                                         if (CheckEHB (Ilbm->camg))
  3228.                                                         {
  3229.                                                            H_LINE = HLine_R_EHB;
  3230.  
  3231.                                                            V_LINE = VLine_R_EHB;
  3232.                                                         }
  3233.  
  3234.                                                         else
  3235.                                                         {
  3236.                                                            H_LINE = HLine_R;
  3237.  
  3238.                                                            V_LINE = VLine_R;
  3239.                                                         }
  3240.                                                      }
  3241.  
  3242.                                                      for (Index = 0; Index <= 10; Index++) if (ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags ^= CHECKED;
  3243.  
  3244.                                                      switch (MAX_ITERATIONS)
  3245.                                                      {
  3246.                                                        case 63 :  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
  3247.  
  3248.                                                                   break;
  3249.  
  3250.                                                        case 127:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags |= CHECKED;
  3251.  
  3252.                                                                   break;
  3253.  
  3254.                                                        case 191:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags |= CHECKED;
  3255.  
  3256.                                                                   break;
  3257.  
  3258.                                                        case 255:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags |= CHECKED;
  3259.  
  3260.                                                                   break;
  3261.  
  3262.                                                        case 319:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags |= CHECKED;
  3263.  
  3264.                                                                   break;
  3265.  
  3266.                                                        case 383:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags |= CHECKED;
  3267.  
  3268.                                                                   break;
  3269.  
  3270.                                                        case 447:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags |= CHECKED;
  3271.  
  3272.                                                                   break;
  3273.  
  3274.                                                        case 511:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags |= CHECKED;
  3275.  
  3276.                                                                   break;
  3277.  
  3278.                                                        case 1023: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags |= CHECKED;
  3279.  
  3280.                                                                   break;
  3281.  
  3282.                                                        default:   if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags |= CHECKED;
  3283.  
  3284.                                                                   break;
  3285.                                                      }
  3286.  
  3287.                                                      if (FUNCTION == Integer)
  3288.                                                      {
  3289.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= CHECKED;
  3290.  
  3291.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags ^= CHECKED;
  3292.  
  3293.                                                         if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags |= CHECKED;
  3294.                                                      }
  3295.  
  3296.                                                      if (FUNCTION == Real)
  3297.                                                      {
  3298.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3299.  
  3300.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags ^= CHECKED;
  3301.  
  3302.                                                         if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
  3303.                                                      }
  3304.  
  3305.                                                      if (FUNCTION == Ppc)
  3306.                                                      {
  3307.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3308.  
  3309.                                                         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= CHECKED;
  3310.  
  3311.                                                         if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags |= CHECKED;
  3312.                                                      }
  3313.  
  3314.                                                      ResetMenuStrip (Ilbm->win,MAINMENU);
  3315.                                                   }
  3316.  
  3317.                                                   else Fail (QueryMandPicError,NULL);
  3318.  
  3319.                                                   FreeIFF (Ilbm->ParseInfo.iff);
  3320.                                                }
  3321.                                             }
  3322.  
  3323.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3324.  
  3325.                                             break;
  3326.                                          }
  3327.  
  3328.                                          if (MyMenu & SAVEPICTURE_MSG)
  3329.                                          {
  3330.                                             if (FileRequest (Ilbm->win,"Save iff picture","PROGDIR:Pictures",PICTURES_DRAWER,TRUE))
  3331.                                             {
  3332.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3333.  
  3334.                                                if (Ilbm->ParseInfo.iff = AllocIFF ())
  3335.                                                {
  3336.                                                   MANDChunk.LeftEdge = Ilbm->win->LeftEdge;
  3337.  
  3338.                                                   MANDChunk.TopEdge = Ilbm->win->TopEdge;
  3339.  
  3340.                                                   MANDChunk.Width = Ilbm->win->Width;
  3341.  
  3342.                                                   MANDChunk.Height = Ilbm->win->Height;
  3343.  
  3344.                                                   MANDChunk.RMin = RMIN;
  3345.  
  3346.                                                   MANDChunk.RMax = RMAX;
  3347.  
  3348.                                                   MANDChunk.IMin = IMIN;
  3349.  
  3350.                                                   MANDChunk.IMax = IMAX;
  3351.  
  3352.                                                   MANDChunk.Iterations = MAX_ITERATIONS + 1L;
  3353.  
  3354.                                                   MANDChunk.Special = NULL;
  3355.  
  3356.                                                   if (SPREAD) MANDChunk.Special |= SPREAD_BIT;
  3357.  
  3358.                                                   if (FUNCTION == Integer) MANDChunk.Special |= INTEGER_BIT;
  3359.  
  3360.                                                   if (FUNCTION == Real) MANDChunk.Special |= REAL_BIT;
  3361.  
  3362.                                                   if (FUNCTION == Ppc) MANDChunk.Special |= PPC_BIT;
  3363.  
  3364.                                                   if (ZMASK & MASK)
  3365.                                                   {
  3366.                                                      DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3367.  
  3368.                                                      MASK ^= ZMASK;
  3369.                                                   }
  3370.  
  3371.                                                   if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3372.  
  3373.                                                   if (SaveMandPic (Ilbm,&SPECIAL_CHUNK,©RIGHT_CHUNK,MYPATH)) Fail (SaveMandPicError,5L);
  3374.  
  3375.                                                   if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3376.  
  3377.                                                   FreeIFF (Ilbm->ParseInfo.iff);
  3378.                                                }
  3379.                                             }
  3380.  
  3381.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3382.  
  3383.                                             break;
  3384.                                          }
  3385.  
  3386.                                          if (MyMenu & LOADPALETTE_MSG)
  3387.                                          {
  3388.                                             if (FileRequest (Ilbm->win,"Load palette","PROGDIR:Palettes",PALETTES_DRAWER,FALSE))
  3389.                                             {
  3390.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3391.  
  3392.                                                if (Ilbm->ParseInfo.iff = AllocIFF ())
  3393.                                                {
  3394.                                                   if (LoadPalette (Ilbm,MYPATH)) Fail (LoadMandPalError,5L);
  3395.  
  3396.                                                   if (Ilbm->EHB) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&(PALETTE [1L]));
  3397.  
  3398.                                                   else GetRGB32 (Ilbm->vp->ColorMap,0L,(ULONG) Ilbm->vp->ColorMap->Count,&(PALETTE [1L]));
  3399.  
  3400.                                                   FreeIFF (Ilbm->ParseInfo.iff);
  3401.                                                }
  3402.  
  3403.                                                else Fail (NoMem,5L);
  3404.                                             }
  3405.  
  3406.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3407.  
  3408.                                             break;
  3409.                                          }
  3410.  
  3411.                                          if (MyMenu & SAVEPALETTE_MSG)
  3412.                                          {
  3413.                                             if (FileRequest (Ilbm->win,"Save palette","PROGDIR:Palettes",PALETTES_DRAWER,TRUE))
  3414.                                             {
  3415.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3416.  
  3417.                                                if (Ilbm->ParseInfo.iff = AllocIFF ())
  3418.                                                {
  3419.                                                   if (SavePalette (Ilbm,©RIGHT_CHUNK,MYPATH)) Fail (SaveMandPalError,5L);
  3420.  
  3421.                                                   FreeIFF (Ilbm->ParseInfo.iff);
  3422.                                                }
  3423.  
  3424.                                                else Fail (NoMem,5L);
  3425.                                             }
  3426.  
  3427.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3428.  
  3429.                                             break;
  3430.                                          }
  3431.  
  3432.                                          if (MyMenu & FONTREQ_MSG)
  3433.                                          {
  3434.                                             if (FontRequest (Ilbm->win))
  3435.                                             {
  3436.                                                if (ZMASK & MASK)
  3437.                                                {
  3438.                                                   DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3439.  
  3440.                                                   MASK ^= ZMASK;
  3441.                                                }
  3442.  
  3443.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3444.  
  3445.                                                MYBITMAP = CopyBitMap (Ilbm->win,Ilbm->win->LeftEdge,Ilbm->win->TopEdge,Ilbm->win->Width,Ilbm->win->Height);
  3446.  
  3447.                                                Fade (MYILBM.win,PALETTE,25L,1L,TOBLACK);
  3448.  
  3449.                                                CloseDisplay (Ilbm,VINFO);
  3450.  
  3451.                                                if (! MakeDisplay (Ilbm))
  3452.                                                {
  3453.                                                   Fail (MakeDisplayError,20L);
  3454.  
  3455.                                                   MyMenu = EXIT_MSG;
  3456.  
  3457.                                                   break;
  3458.                                                }
  3459.  
  3460.                                                PasteBitMap (MYBITMAP,Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
  3461.                                             }
  3462.  
  3463.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3464.  
  3465.                                             break;
  3466.                                          }
  3467.  
  3468.                                          if (MyMenu & DUMP_MSG)
  3469.                                          {
  3470.                                             ModifyIDCMP (Ilbm->win,NULL);
  3471.  
  3472.                                             ClearMenuStrip (Ilbm->win);
  3473.  
  3474.                                             PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3475.  
  3476.                                             if (Choice (Ilbm->win,"Print requester","Are you sure ?"))
  3477.                                             {
  3478.                                                WinDump (Ilbm->win);
  3479.                                             }
  3480.  
  3481.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3482.  
  3483.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3484.  
  3485.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3486.  
  3487.                                             break;
  3488.                                          }
  3489.  
  3490.                                          if (MyMenu & PREVIEW_MSG)
  3491.                                          {
  3492.                                             if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
  3493.                                             {
  3494.                                                ModifyIDCMP (Ilbm->win,NULL);
  3495.  
  3496.                                                ClearMenuStrip (Ilbm->win);
  3497.  
  3498.                                                Preview (Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
  3499.  
  3500.                                                ResetMenuStrip (Ilbm->win,MAINMENU);
  3501.  
  3502.                                                ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3503.  
  3504.                                                RestoreCoords ();
  3505.                                             }
  3506.  
  3507.                                             break;
  3508.                                          }
  3509.  
  3510.                                          if (MyMenu & COORDS_MSG)
  3511.                                          {
  3512.                                             ModifyIDCMP (Ilbm->win,NULL);
  3513.  
  3514.                                             ClearMenuStrip (Ilbm->win);
  3515.  
  3516.                                             if (ShowCoords (Ilbm->win))
  3517.                                             {
  3518.                                                if (Choice (Ilbm->win,"Rendering requester","Recalculate ?")) MyMenu |= REDRAW_MSG;
  3519.                                             }
  3520.  
  3521.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3522.  
  3523.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3524.                                          }
  3525.  
  3526.                                          if (MyMenu & REDRAW_MSG)
  3527.                                          {
  3528.                                             if (ZMASK & MASK)
  3529.                                             {
  3530.                                                DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3531.  
  3532.                                                MASK ^= ZMASK;
  3533.                                             }
  3534.  
  3535.                                             SetMenuStop (Ilbm->win);
  3536.  
  3537.                                             PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3538.  
  3539.                                             ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3540.  
  3541.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3542.  
  3543.                                             SetMenuStart (Ilbm->win);
  3544.  
  3545.                                             ShowTime (Ilbm->win,"Recalculate elapsed time:",ELAPSEDTIME);
  3546.  
  3547.                                             break;
  3548.                                          }
  3549.  
  3550.                                          if (MyMenu & UNDO_MSG)
  3551.                                          {
  3552.                                             if (ZMASK & MASK)
  3553.                                             {
  3554.                                                DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3555.  
  3556.                                                MASK ^= ZMASK;
  3557.                                             }
  3558.  
  3559.                                             RestoreCoords ();
  3560.  
  3561.                                             PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3562.  
  3563.                                             SetMenuStop (Ilbm->win);
  3564.  
  3565.                                             Fade (MYILBM.win,PALETTE,25L,1L,TOBLACK);
  3566.  
  3567.                                             ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3568.  
  3569.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3570.  
  3571.                                             SetMenuStart (Ilbm->win);
  3572.  
  3573.                                             ShowTime (Ilbm->win,"Undo elapsed time:",ELAPSEDTIME);
  3574.  
  3575.                                             break;
  3576.                                          }
  3577.  
  3578.                                          if (MyMenu & DRAW_MSG)
  3579.                                          {
  3580.                                             if (ZMASK & MASK)
  3581.                                             {
  3582.                                                DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3583.  
  3584.                                                MASK ^= ZMASK;
  3585.                                             }
  3586.  
  3587.                                             if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
  3588.                                             {
  3589.                                                MYBITMAP = CopyBitMap (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  3590.  
  3591.                                                PasteBitMap (MYBITMAP,Ilbm->win,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  3592.  
  3593.                                                SetMenuStop (Ilbm->win);
  3594.  
  3595.                                                PutPointer (Ilbm->win,0,0,0,0,0,BUSY_POINTER);
  3596.  
  3597.                                                ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3598.  
  3599.                                                PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3600.  
  3601.                                                SetMenuStart (Ilbm->win);
  3602.  
  3603.                                                ShowTime (Ilbm->win,"Zoom elapsed time:",ELAPSEDTIME);
  3604.                                             }
  3605.  
  3606.                                             break;
  3607.                                          }
  3608.  
  3609.                                          break;
  3610.  
  3611.                 case       IDCMP_RAWKEY: if (MyCode == RAW_ESC) MyMenu = EXIT_MSG;
  3612.  
  3613.                                          break;
  3614.  
  3615.                 case  IDCMP_CLOSEWINDOW: MyMenu = EXIT_MSG;
  3616.          }
  3617.       }
  3618.  
  3619.     } while (! ((MyMenu & EXIT_MSG) || (MyMenu & NEWDISPLAY_MSG)));
  3620.  
  3621.  return MyMenu;
  3622. }
  3623.  
  3624. struct BitMap *CopyBitMap (struct Window *Win,WORD Left,WORD Top,WORD Width,WORD Height)
  3625. {
  3626. struct BitMap *NewBM;
  3627.  
  3628.   NewBM = AllocBitMap ((ULONG) Width,(ULONG) Height,(ULONG) Win->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,Win->RPort->BitMap);
  3629.  
  3630.   if (NewBM)
  3631.   {
  3632.      if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
  3633.  
  3634.      if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
  3635.  
  3636.      BltBitMap (Win->RPort->BitMap,(LONG) Left,(LONG) Top,NewBM,0,0,(LONG) Width,(LONG) Height,0xC0,0xFF,NULL);
  3637.  
  3638.      if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
  3639.  
  3640.      if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
  3641.  
  3642.      MASK |= BMASK;
  3643.   }
  3644.  
  3645.   return NewBM;
  3646. }
  3647.  
  3648. BOOL PasteBitMap (struct BitMap *SrcBM,struct Window *DstWin,WORD SrcWidth,WORD SrcHeight)
  3649. {
  3650. BOOL Success = FALSE;
  3651.  
  3652. ULONG DstWinWidth,DstWinHeight;
  3653.  
  3654. struct BitMap *TmpBM;
  3655.  
  3656.   if (SrcBM)
  3657.   {
  3658.      DstWinWidth = (ULONG) ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZWidth : DstWin->Width);
  3659.  
  3660.      DstWinHeight = (ULONG) ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZHeight : DstWin->Height);
  3661.  
  3662.      TmpBM = AllocBitMap ((ULONG) DstWinWidth,(ULONG) DstWinHeight,(ULONG) DstWin->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,DstWin->RPort->BitMap);
  3663.  
  3664.      if (TmpBM)
  3665.      {
  3666.         BSA.bsa_SrcWidth    = SrcWidth;
  3667.         BSA.bsa_SrcHeight   = SrcHeight;
  3668.         BSA.bsa_XSrcFactor  = SrcWidth;
  3669.         BSA.bsa_YSrcFactor  = SrcHeight;
  3670.         BSA.bsa_XDestFactor = DstWinWidth;
  3671.         BSA.bsa_YDestFactor = DstWinHeight;
  3672.         BSA.bsa_SrcBitMap   = SrcBM;
  3673.         BSA.bsa_DestBitMap  = TmpBM;
  3674.  
  3675.         BitMapScale (&BSA);
  3676.  
  3677.         BltBitMapRastPort (TmpBM,0,0,DstWin->RPort,0,0,DstWinWidth,DstWinHeight,0xC0);
  3678.  
  3679.         FreeBitMap (TmpBM);
  3680.  
  3681.         Success = TRUE;
  3682.      }
  3683.  
  3684.      FreeBitMap (SrcBM);
  3685.  
  3686.      MASK ^= BMASK;
  3687.   }
  3688.  
  3689.   return Success;
  3690. }
  3691.  
  3692. LONG WinDump (struct Window *Win)
  3693. {
  3694. struct IODRPReq *IODrp;
  3695. struct MsgPort  *PrinterPort;
  3696. struct ViewPort *Vp;
  3697.  
  3698. LONG Error = PDERR_BADDIMENSION;
  3699.  
  3700.   if (! Win) return Error;
  3701.  
  3702.   if (PrinterPort = CreatePort (0,0))
  3703.   {
  3704.      if (IODrp = (struct IODRPReq *) CreateExtIO (PrinterPort,sizeof (struct IODRPReq)))
  3705.      {
  3706.         if (! (Error = OpenDevice ("printer.device",0,(struct IORequest *) IODrp,0)))
  3707.         {
  3708.            Vp = ViewPortAddress (Win);
  3709.  
  3710.            IODrp->io_Command   = PRD_DUMPRPORT;
  3711.            IODrp->io_RastPort  = Win->RPort;
  3712.            IODrp->io_ColorMap  = Vp->ColorMap;
  3713.            IODrp->io_Modes     = (ULONG) Vp->Modes;
  3714.            IODrp->io_SrcX      = Win->LeftEdge;
  3715.            IODrp->io_SrcY      = Win->TopEdge;
  3716.            IODrp->io_SrcWidth  = Win->Width;
  3717.            IODrp->io_SrcHeight = Win->Height;
  3718.            IODrp->io_DestCols  = 0;
  3719.            IODrp->io_Special   = SPECIAL_FULLCOLS | SPECIAL_ASPECT;
  3720.  
  3721.            Error = DoIO ((struct IORequest *)IODrp);
  3722.  
  3723.            CloseDevice ((struct IORequest *)IODrp);
  3724.         }
  3725.  
  3726.         DeleteExtIO ((struct IORequest *)IODrp);
  3727.      }
  3728.  
  3729.      DeletePort (PrinterPort);
  3730.   }
  3731.  
  3732.   return Error;
  3733. }
  3734.  
  3735. ULONG Fail (UBYTE *ErrorString,ULONG ErrorLevel)
  3736. {
  3737.   DisplayAlert (RECOVERY_ALERT,ErrorString,30);
  3738.  
  3739.   RETURNVALUE = ErrorLevel;
  3740.  
  3741.   return RETURNVALUE;
  3742. }
  3743.  
  3744. LONG main (ULONG Argc,UBYTE **Argv)
  3745. {
  3746. UBYTE **ToolTypes;
  3747.  
  3748.   if ((ToolTypes = ArgArrayInit (Argc,Argv)))
  3749.   {
  3750.      MYILBM.Bmhd.w       = ArgInt (ToolTypes,"SCREENWIDTH",DEF_WIDTH);
  3751.      MYILBM.Bmhd.h       = ArgInt (ToolTypes,"SCREENHEIGHT",DEF_HEIGHT);
  3752.      MYILBM.Bmhd.nPlanes = ArgInt (ToolTypes,"SCREENDEPTH",MAX_DEPTH);
  3753.  
  3754.      sscanf (ArgString (ToolTypes,"SCREENMODE",DEF_MONITORSTR),"%lx",&MYILBM.camg);
  3755.  
  3756.      sscanf (ArgString (ToolTypes,"REALMIN",INIT_DEF_RMINSTR),"%lf",&RMIN);
  3757.      sscanf (ArgString (ToolTypes,"REALMAX",INIT_DEF_RMAXSTR),"%lf",&RMAX);
  3758.      sscanf (ArgString (ToolTypes,"IMAGMIN",INIT_DEF_IMINSTR),"%lf",&IMIN);
  3759.      sscanf (ArgString (ToolTypes,"IMAGMAX",INIT_DEF_IMAXSTR),"%lf",&IMAX);
  3760.  
  3761.      strncpy (MYFONTSTRUCT.ta_Name,ArgString (ToolTypes,"FONTNAME",DEF_FONTNAME),24);
  3762.  
  3763.      MYFONTSTRUCT.ta_YSize = ArgInt (ToolTypes,"FONTSIZE",DEF_FONTSIZE);
  3764.  
  3765.      PRIORITY = ArgInt (ToolTypes,"STARTPRI",DEF_STARTPRI);
  3766.  
  3767.      ArgArrayDone ();
  3768.  
  3769.      MYILBM.Bmhd.w = MIN (MAX_WIDTH,MAX (MYILBM.Bmhd.w,DEF_WIDTH));
  3770.  
  3771.      MYILBM.Bmhd.h = MIN (MAX_HEIGHT,MAX (MYILBM.Bmhd.h,DEF_HEIGHT));
  3772.  
  3773.      MYILBM.Bmhd.nPlanes = MIN (MAX_DEPTH,MAX (MYILBM.Bmhd.nPlanes,MIN_DEPTH));
  3774.  
  3775.      MYFONTSTRUCT.ta_YSize = MIN (MAX_FONTSIZE,MAX (MYFONTSTRUCT.ta_YSize,MIN_FONTSIZE));
  3776.  
  3777.      PRIORITY = MIN (5,MAX (PRIORITY,-5));
  3778.   }
  3779.  
  3780.   else
  3781.   {
  3782.      MYILBM.camg = DEF_MONITOR;
  3783.  
  3784.      MYILBM.Bmhd.w = DEF_WIDTH;
  3785.  
  3786.      MYILBM.Bmhd.h = DEF_HEIGHT;
  3787.  
  3788.      MYILBM.Bmhd.nPlanes = (CheckGFX () ? MAX_DEPTH : DEF_DEPTH);
  3789.   }
  3790.  
  3791.   if (ModeNotAvailable (MYILBM.camg)) MYILBM.camg = ModeFallBack (MYILBM.camg,MYILBM.Bmhd.w,MYILBM.Bmhd.h,MYILBM.Bmhd.nPlanes);
  3792.  
  3793.   if (MYILBM.Bmhd.nPlanes > GetMaxPlanes (MYILBM.camg)) MYILBM.Bmhd.nPlanes = GetMaxPlanes (MYILBM.camg);
  3794.  
  3795.   if (MYILBM.Bmhd.nPlanes < MIN_DEPTH)
  3796.   {
  3797.      Fail (OpenDisplayError,20L);
  3798.  
  3799.      exit (RETURNVALUE);
  3800.   }
  3801.  
  3802.   PALETTE = (CheckGFX () ? COLORS_AGA : COLORS_ECS);
  3803.  
  3804.   if ((RMIN >= RMAX) || (IMIN >= IMAX))
  3805.   {
  3806.     DEF_RMIN = INIT_DEF_RMIN;
  3807.  
  3808.     DEF_RMAX = INIT_DEF_RMAX;
  3809.  
  3810.     DEF_IMIN = INIT_DEF_IMIN;
  3811.  
  3812.     DEF_IMAX = INIT_DEF_IMAX;
  3813.   }
  3814.  
  3815.   else
  3816.   {
  3817.     DEF_RMIN = RMIN;
  3818.  
  3819.     DEF_RMAX = RMAX;
  3820.  
  3821.     DEF_IMIN = IMIN;
  3822.  
  3823.     DEF_IMAX = IMAX;
  3824.   }
  3825.  
  3826.   SaveCoords ();
  3827.  
  3828.   MYILBM.ParseInfo.propchks = IlbmProps;
  3829.  
  3830.   MYILBM.ParseInfo.collectchks = IlbmCollects;
  3831.  
  3832.   MYILBM.ParseInfo.stopchks = IlbmStops;
  3833.  
  3834.   MYILBM.Bmhd.pageWidth  = 0;
  3835.  
  3836.   MYILBM.Bmhd.pageHeight = 0;
  3837.  
  3838.   MYILBM.stype = CUSTOMSCREEN | SCREENQUIET;
  3839.  
  3840.   MYILBM.TBState = TMASK & MASK;
  3841.  
  3842.   MYILBM.ucliptype = OSCAN_TEXT;
  3843.  
  3844.   MYILBM.EHB = TRUE;
  3845.  
  3846.   MYILBM.Autoscroll = TRUE;
  3847.  
  3848.   MYILBM.IFFPFlags = NULL;
  3849.  
  3850.   FUNCTION = Integer;
  3851.  
  3852.   H_LINE = HLine_S;
  3853.  
  3854.   V_LINE = VLine_S;
  3855.  
  3856.   if (MAINMENU = CreateMenus (ProgMenu,TAG_END))
  3857.   {
  3858.      if (MYILBM.Bmhd.nPlanes < 6)
  3859.      {
  3860.         MAX_ITERATIONS = 63;
  3861.  
  3862.         ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags ^= CHECKED;
  3863.  
  3864.         ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
  3865.      }
  3866.  
  3867.      if (CheckEHB (MYILBM.camg))
  3868.      {
  3869.         H_LINE = HLine_S_EHB;
  3870.  
  3871.         V_LINE = VLine_S_EHB;
  3872.      }
  3873.  
  3874.      if (CheckFPU (SysBase->AttnFlags) & FPU_68K)
  3875.      {
  3876.         FUNCTION = Real;
  3877.  
  3878.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= NM_ITEMDISABLED;
  3879.  
  3880.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3881.  
  3882.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
  3883.      }
  3884.  
  3885.      if (CheckFPU (SysBase->AttnFlags) & FPU_PPC)
  3886.      {
  3887.         FUNCTION = Ppc;
  3888.  
  3889.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags ^= NM_ITEMDISABLED;
  3890.  
  3891.         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags == CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3892.  
  3893.         if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags == CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= CHECKED;
  3894.  
  3895.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,2))->Flags |= CHECKED;
  3896.      }
  3897.  
  3898.      switch (PRIORITY)
  3899.      {
  3900.        case -5: ItemAddress (MAINMENU,FULLMENUNUM (1,3,0))->Flags |= CHECKED;
  3901.  
  3902.                 break;
  3903.  
  3904.        case -4: ItemAddress (MAINMENU,FULLMENUNUM (1,3,1))->Flags |= CHECKED;
  3905.  
  3906.                 break;
  3907.  
  3908.        case -3: ItemAddress (MAINMENU,FULLMENUNUM (1,3,2))->Flags |= CHECKED;
  3909.  
  3910.                 break;
  3911.  
  3912.        case -2: ItemAddress (MAINMENU,FULLMENUNUM (1,3,3))->Flags |= CHECKED;
  3913.  
  3914.                 break;
  3915.  
  3916.        case -1: ItemAddress (MAINMENU,FULLMENUNUM (1,3,4))->Flags |= CHECKED;
  3917.  
  3918.                 break;
  3919.  
  3920.        case  0: ItemAddress (MAINMENU,FULLMENUNUM (1,3,6))->Flags |= CHECKED;
  3921.  
  3922.                 break;
  3923.  
  3924.        case  1: ItemAddress (MAINMENU,FULLMENUNUM (1,3,8))->Flags |= CHECKED;
  3925.  
  3926.                 break;
  3927.  
  3928.        case  2: ItemAddress (MAINMENU,FULLMENUNUM (1,3,9))->Flags |= CHECKED;
  3929.  
  3930.                 break;
  3931.  
  3932.        case  3: ItemAddress (MAINMENU,FULLMENUNUM (1,3,10))->Flags |= CHECKED;
  3933.  
  3934.                 break;
  3935.  
  3936.        case  4: ItemAddress (MAINMENU,FULLMENUNUM (1,3,11))->Flags |= CHECKED;
  3937.  
  3938.                 break;
  3939.  
  3940.        case  5: ItemAddress (MAINMENU,FULLMENUNUM (1,3,12))->Flags |= CHECKED;
  3941.  
  3942.                 break;
  3943.      }
  3944.  
  3945.      SetTaskPri (FindTask (NULL),PRIORITY);
  3946.  
  3947.      if (CURRENT_MAX_COLORS = MakeDisplay (&MYILBM))
  3948.      {
  3949.         CURRENT_MAX_COLORS -= RESERVED_PENS;
  3950.  
  3951.         MANDChunk.LeftEdge = MYILBM.win->LeftEdge;
  3952.  
  3953.         MANDChunk.TopEdge = MYILBM.win->TopEdge;
  3954.  
  3955.         MANDChunk.Width = MYILBM.win->Width;
  3956.  
  3957.         MANDChunk.Height = MYILBM.win->Height;
  3958.  
  3959.         MANDChunk.RMin = RMIN;
  3960.  
  3961.         MANDChunk.RMax = RMAX;
  3962.  
  3963.         MANDChunk.IMin = IMIN;
  3964.  
  3965.         MANDChunk.IMax = IMAX;
  3966.  
  3967.         MANDChunk.Iterations = MAX_ITERATIONS + 1L;
  3968.  
  3969.         MANDChunk.Special = NULL;
  3970.  
  3971.         SPECIAL_CHUNK.ch_Data = &MANDChunk;
  3972.  
  3973.         PutPointer (MYILBM.win,0,0,0,0,0,BUSY_POINTER);
  3974.  
  3975.         ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
  3976.  
  3977.         PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  3978.  
  3979.         SetMenuStart (MYILBM.win);
  3980.  
  3981.         ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
  3982.  
  3983.         ModifyIDCMP (MYILBM.win,NULL);
  3984.  
  3985.         ClearMenuStrip (MYILBM.win);
  3986.  
  3987.         About (MYILBM.win);
  3988.  
  3989.         ResetMenuStrip (MYILBM.win,MAINMENU);
  3990.  
  3991.         ModifyIDCMP (MYILBM.win,IDCMP_STANDARD);
  3992.  
  3993.         do
  3994.         {
  3995.           while (HandleEvents (&MYILBM) & NEWDISPLAY_MSG)
  3996.           {
  3997.                 if (SMRequest (&MYILBM))
  3998.                 {
  3999.                    if (ZMASK & MASK)
  4000.                    {
  4001.                       DrawBorder (MYILBM.wrp,&MYBORDER,0,0);
  4002.  
  4003.                       MASK ^= ZMASK;
  4004.                    }
  4005.  
  4006.                    MYBITMAP = CopyBitMap (MYILBM.win,MYILBM.win->LeftEdge,MYILBM.win->TopEdge,MYILBM.win->Width,MYILBM.win->Height);
  4007.  
  4008.                    Fade (MYILBM.win,PALETTE,25L,1L,TOBLACK);
  4009.  
  4010.                    CloseDisplay (&MYILBM,VINFO);
  4011.  
  4012.                    MYILBM.Bmhd.pageWidth  = 0;
  4013.  
  4014.                    MYILBM.Bmhd.pageHeight = 0;
  4015.  
  4016.                    CURRENT_MAX_COLORS = MakeDisplay (&MYILBM);
  4017.  
  4018.                    if (CURRENT_MAX_COLORS)
  4019.                    {
  4020.                       CURRENT_MAX_COLORS -= RESERVED_PENS;
  4021.  
  4022.                       PasteBitMap (MYBITMAP,MYILBM.win,(WORD) GetBitMapAttr (MYBITMAP,BMA_WIDTH),(WORD) GetBitMapAttr (MYBITMAP,BMA_HEIGHT));
  4023.  
  4024.                       if (CheckEHB (MYILBM.camg))
  4025.                       {
  4026.                          if (SPREAD == FALSE)
  4027.                          {
  4028.                             H_LINE = HLine_R_EHB;
  4029.  
  4030.                             V_LINE = VLine_R_EHB;
  4031.                          }
  4032.  
  4033.                          else
  4034.                          {
  4035.                             H_LINE = HLine_S_EHB;
  4036.  
  4037.                             V_LINE = VLine_S_EHB;
  4038.                          }
  4039.                       }
  4040.  
  4041.                       else
  4042.                       {
  4043.                          if (SPREAD == FALSE)
  4044.                          {
  4045.                             H_LINE = HLine_R;
  4046.  
  4047.                             V_LINE = VLine_R;
  4048.                          }
  4049.  
  4050.                          else
  4051.                          {
  4052.                             H_LINE = HLine_S;
  4053.  
  4054.                             V_LINE = VLine_S;
  4055.                          }
  4056.                       }
  4057.  
  4058.                       if (Choice (MYILBM.win,"Rendering requester","Screen propreties are changed.\nImage and colors can be inaccurate.\n\nRecalculate ?"))
  4059.                       {
  4060.                          SetMenuStop (MYILBM.win);
  4061.  
  4062.                          PutPointer (MYILBM.win,0,0,0,0,0,BUSY_POINTER);
  4063.  
  4064.                          ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
  4065.  
  4066.                          PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,ZOOM_POINTER);
  4067.  
  4068.                          SetMenuStart (MYILBM.win);
  4069.  
  4070.                          ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
  4071.                       }
  4072.                   }
  4073.  
  4074.                   else
  4075.                   {
  4076.                          Fail (MakeDisplayError,20L);
  4077.  
  4078.                          break;
  4079.                   }
  4080.                 }
  4081.           }
  4082.  
  4083.           if (RETURNVALUE >= 20L) break;
  4084.  
  4085.         } while (! Choice (MYILBM.win,"Exit requester","Are you sure ?"));
  4086.  
  4087.         if (BMASK & MASK) FreeBitMap (MYBITMAP);
  4088.      }
  4089.  
  4090.      else Fail (MakeDisplayError,20L);
  4091.  
  4092.      Fade (MYILBM.win,PALETTE,50L,1L,TOBLACK);
  4093.  
  4094.      CloseDisplay (&MYILBM,VINFO);
  4095.  
  4096.      FreeMenus (MAINMENU);
  4097.   }
  4098.  
  4099.   else Fail (MenuError,20L);
  4100.  
  4101.   exit (RETURNVALUE);
  4102. }
  4103.